Skip to content

Commit

Permalink
Onboarding Functionning
Browse files Browse the repository at this point in the history
  • Loading branch information
DEKHTIARJonathan committed Aug 13, 2017
1 parent 0615892 commit 3ad41fc
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 24 deletions.
8 changes: 4 additions & 4 deletions feedcrunch/model_files/models_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def is_social_network_enabled(self, network=None):
return bool(self.rel_slack_integrations.all().count())

else:
raise Exception("The network requested " + network + "doesn't exist in this application")
raise Exception("The network requested " + network + " doesn't exist in this application")


def is_twitter_enabled(self):
Expand Down Expand Up @@ -585,21 +585,21 @@ def is_social_network_activated(self, network):
return False

else:
raise Exception("The network requested " + network + "doesn't exist in this application")
raise Exception("The network requested " + network + " doesn't exist in this application")

def reset_social_network_credentials(self, network):
if network in ["facebook", "linkedin"]:
setattr(self, self.social_fields[network]["token"], "")
setattr(self, self.social_fields[network]["expire_datetime"], None)

elif network == "twittter":
elif network == "twitter":
setattr(self, self.social_fields[network]["token"], "")
setattr(self, self.social_fields[network]["secret"], "")

elif network == "slack":
self.rel_slack_integrations.all().delete()
else:
raise Exception("The network requested " + network + "doesn't exist in this application")
raise Exception("The network requested " + network + " doesn't exist in this application")

self.save()
################################### ============================== ###################################
Expand Down
2 changes: 1 addition & 1 deletion feedcrunch_rssadmin/static/js/admin-social-linking.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $(document).ready(function() {
var social_networks_dict = {
twitter: "#twitter-btn-div",
facebook: "#facebook-btn-div",
linkedin: "#linkedin-btn-div",
linkedin: "192",
slack: "#slack-btn-div",
};

Expand Down
1 change: 1 addition & 0 deletions feedcrunch_rssadmin/static/onboarding/css/onboarding.css
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ a:focus, a:hover {
@media (max-height: 799px) {
.personal_form{
margin-top: 15px;
margin-bottom: 0px;
}
}

Expand Down
10 changes: 9 additions & 1 deletion feedcrunch_rssadmin/static/onboarding/js/onboarding.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,16 @@ $( document ).ready(function() {
for (field in form_fields){
//console.log(social_networks[field]+ " = " +$("#"+social_networks[field]).val());
var input = $("#"+form_fields[field]);
input.val(input.data("init"));
var data = input.data("init");

if (data != ""){
$("label[for='" + form_fields[field] + "']").addClass("active");
console.log(form_fields[field]);
}

input.val(data);
}

$("#country").material_select();
$("#gender").material_select();
}
Expand Down
56 changes: 41 additions & 15 deletions feedcrunch_rssadmin/templates/admin/onboarding.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,17 @@
<!-- Styles -->
<link type="text/css" rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/css/bootstrap.min.css">
<link type="text/css" rel="stylesheet" href="{% static "plugins/materialize/css/materialize.min.css" %}"/>
<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.1/css/materialize.css" integrity="sha256-hjogeqn8q8sMZJjGea/UNQJGikkDn0quFnnsn6p1x88=" crossorigin="anonymous" /> -->
<link type="text/css" rel="stylesheet" href="{% static "plugins/metrojs/MetroJs.min.css" %}"/>
<link type="text/css" rel="stylesheet" href="{% static "plugins/sweetalert/sweetalert.css" %}">

<!-- Theme Styles -->
<link type="text/css" rel="stylesheet" href="{% static "css/alpha.min.css" %}"/>
<link type="text/css" rel="stylesheet" href="{% static "onboarding/css/onboarding.css" %}">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="http://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="http://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<script src="http://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="http://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
Expand Down Expand Up @@ -100,6 +99,7 @@
</div>
</nav>
</header>

<main class="mn-inner">
<div class="row">
<!-- progressbar -->
Expand All @@ -108,6 +108,7 @@
<li>Social Profiles</li>
<li>Personal Details</li>
</ul>

<!-- fieldsets -->
<fieldset class="onboarding_fieldset">
<div class="col-md-12 fieldset-div">
Expand Down Expand Up @@ -146,6 +147,7 @@ <h2 class="hide_laptop">Learn</h2>
<button type="button" id="interests-btn" class="btn col-md-3 blue darken-2 m-b-xs next" disabled>Select 3 Interests to Continue ...</button>
</div>
</fieldset>

<fieldset class="onboarding_fieldset">
<div class="col-md-12 fieldset-div">
<div class="col-lg-3 hidden-md-down side-panel">
Expand Down Expand Up @@ -186,9 +188,13 @@ <h2 class="hide_laptop">Create Opportunities</h2>
<div class="row social-btn-row">
<div class="col s12" id="twitter-btn-div">
{% if twitter_auth_url %}
<a href="{{ twitter_auth_url }}" target="_target" class="btn waves-effect waves-light indigo accent-3 twitter-btn" id="twitter-btn-link">Link My Twitter Account</a>
<a href="{{ twitter_auth_url }}" target="_target" class="waves-effect waves-light btn blue socialconnect-btn" id="twitter-btn-link">
Link My Twitter Account
</a>
{% else %}
<button class="waves-effect waves-light btn red twitter-btn" id="twitter-btn-unlink">Unlink My Twitter Account</button>
<button class="waves-effect waves-light btn red twitter-btn socialconnect-btn" id="twitter-btn-unlink">
Unlink My Twitter Account
</button>
{% endif %}
</div>
</div>
Expand All @@ -209,8 +215,16 @@ <h2 class="hide_laptop">Create Opportunities</h2>
</figure>
<div class="card-content">
<div class="row social-btn-row">
<div class="col s12" style="text-align: center;">
<button class="btn waves-effect waves-light red" type="submit" name="action" style="font-size: 12px;" disabled="">Coming Soon</button>
<div class="col s12" id="facebook-btn-div">
{% if facebook_auth_url %}
<a href="{{ facebook_auth_url }}" target="_target" class="waves-effect waves-light btn blue socialconnect-btn" id="facebook-btn-link">
Link My Facebook Account
</a>
{% else %}
<button class="waves-effect waves-light btn red socialconnect-btn" id="facebook-btn-unlink">
Unlink My Facebook Account
</button>
{% endif %}
</div>
</div>
</div>
Expand All @@ -230,16 +244,24 @@ <h2 class="hide_laptop">Create Opportunities</h2>
</figure>
<div class="card-content">
<div class="row social-btn-row">
<div class="col s12" style="text-align: center;">
<button class="btn waves-effect waves-light red" type="submit" name="action" style="font-size: 12px;" disabled="">Coming Soon</button>
<div class="col s12" id="linkedin-btn-div">
{% if linkedin_auth_url %}
<a href="{{ linkedin_auth_url }}" target="_target" class="waves-effect waves-light btn blue socialconnect-btn" id="linkedin-btn-link">
Link My Linkedin Account
</a>
{% else %}
<button class="waves-effect waves-light btn red socialconnect-btn" id="linkedin-btn-unlink">
Unlink My Linkedin Account
</button>
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>

<!-- GooglePlus Card -->
<!-- Slack Card -->
<div class="col s12 m6 social_card">
<div class="white height100">
<div class="card" id="profile-page-header">
Expand Down Expand Up @@ -267,9 +289,10 @@ <h2 class="hide_laptop">Create Opportunities</h2>
<a type="button" name="next" class="btn col-md-3 blue darken-2 m-b-xs next">Next Step</a>
</div>
</fieldset>

<fieldset class="onboarding_fieldset">
<form action="../process_onboarding/" method="post" id="onboarding_form">
<div class="wizard clearfix">
<form action="../process_onboarding/" method="post" id="onboarding_form" class="height100">
<div class="wizard clearfix height100">
<div class="steps clearfix">
<ul style="width: 100%;" class="tabs">
<li class="tab">
Expand Down Expand Up @@ -373,20 +396,23 @@ <h2 class="hide_laptop">Create Opportunities</h2>
</section>
</div>
</form>

</fieldset>

</div>
</main>

</div>

<!-- Javascripts -->
<script type="text/javascript" src="{% static "plugins/jquery/jquery-2.2.0.min.js" %}"></script>
<script type="text/javascript" src="{% static "plugins/materialize/js/materialize.min.js" %}"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.1/js/materialize.min.js" integrity="sha256-3mqgTUhHNgfXgjrzjPOaW03DdQ9hgW92BApzLREoRoA=" crossorigin="anonymous"></script> -->
<script type="text/javascript" src="{% static "plugins/material-preloader/js/materialPreloader.min.js" %}"></script>
<script type="text/javascript" src="{% static "plugins/sweetalert/sweetalert.min.js" %}"></script>
<script type="text/javascript" src="{% static "plugins/js-cookie/js.cookie-2.1.3.min.js" %}"></script>
<script type="text/javascript" src="{% static "js/admin-social-linking.js" %}"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.16.0/jquery.validate.min.js" integrity="sha256-UOSXsAgYN43P/oVrmU+JlHtiDGYWN2iHnJuKY9WD+Jg=" crossorigin="anonymous"></script>
<script type="text/javascript" src="{% static "js/alpha.min.js" %}"></script>
<script type="text/javascript" src="{% static "js/admin-social-linking.js" %}"></script>
<script type="text/javascript" src="{% static "onboarding/js/onboarding.js" %}"></script>
</body>
</html>
23 changes: 20 additions & 3 deletions feedcrunch_rssadmin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,29 @@ def onboarding_view(request, feedname=None):
interest_list = Interest.objects.all().order_by('name')
country_list = Country.objects.all().order_by('name')

request_data = dict()

if not request.user.is_social_network_activated(network="twitter"):
twitter_auth_url = TwitterAPI.get_authorization_url(request)
request_data["twitter_auth_url"] = TwitterAPI.get_authorization_url(request)
else:
request_data["twitter_auth_url"] = False # False => Don't need to authenticate with Twitter

if not request.user.is_social_network_activated(network="facebook"):
request_data["facebook_auth_url"] = FacebookAPI.get_authorization_url()
else:
twitter_auth_url = False # False => Don't need to authenticate with Twitter
request_data["facebook_auth_url"] = False # False => Don't need to authenticate with Facebook

if not request.user.is_social_network_activated(network="linkedin"):
request_data["linkedin_auth_url"] = LinkedInAPI.get_authorization_url()
else:
request_data["linkedin_auth_url"] = False # False => Don't need to authenticate with LinkedIn

request_data["slack_auth_url"] = SlackAPI.get_authorization_url()

request_data['interests'] = interest_list
request_data['countries'] = country_list

return render(request, 'admin/onboarding.html', {'interests': interest_list, 'countries': country_list, 'twitter_auth_url': twitter_auth_url})
return render(request, 'admin/onboarding.html', request_data)

def process_onboarding_view(request, feedname=None):

Expand Down

0 comments on commit 3ad41fc

Please sign in to comment.