From 3ad41fcbea36b7c4ce623555f969328406f19fd0 Mon Sep 17 00:00:00 2001 From: DEKHTIARJonathan Date: Mon, 14 Aug 2017 00:46:18 +0200 Subject: [PATCH] Onboarding Functionning --- feedcrunch/model_files/models_user.py | 8 +-- .../static/js/admin-social-linking.js | 2 +- .../static/onboarding/css/onboarding.css | 1 + .../static/onboarding/js/onboarding.js | 10 +++- .../templates/admin/onboarding.html | 56 ++++++++++++++----- feedcrunch_rssadmin/views.py | 23 +++++++- 6 files changed, 76 insertions(+), 24 deletions(-) diff --git a/feedcrunch/model_files/models_user.py b/feedcrunch/model_files/models_user.py index b6baabc..83985c0 100644 --- a/feedcrunch/model_files/models_user.py +++ b/feedcrunch/model_files/models_user.py @@ -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): @@ -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() ################################### ============================== ################################### diff --git a/feedcrunch_rssadmin/static/js/admin-social-linking.js b/feedcrunch_rssadmin/static/js/admin-social-linking.js index ae803a9..192ac7e 100644 --- a/feedcrunch_rssadmin/static/js/admin-social-linking.js +++ b/feedcrunch_rssadmin/static/js/admin-social-linking.js @@ -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", }; diff --git a/feedcrunch_rssadmin/static/onboarding/css/onboarding.css b/feedcrunch_rssadmin/static/onboarding/css/onboarding.css index 7a92f57..fd68750 100644 --- a/feedcrunch_rssadmin/static/onboarding/css/onboarding.css +++ b/feedcrunch_rssadmin/static/onboarding/css/onboarding.css @@ -533,6 +533,7 @@ a:focus, a:hover { @media (max-height: 799px) { .personal_form{ margin-top: 15px; + margin-bottom: 0px; } } diff --git a/feedcrunch_rssadmin/static/onboarding/js/onboarding.js b/feedcrunch_rssadmin/static/onboarding/js/onboarding.js index e67ab10..5eb6fd3 100644 --- a/feedcrunch_rssadmin/static/onboarding/js/onboarding.js +++ b/feedcrunch_rssadmin/static/onboarding/js/onboarding.js @@ -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(); } diff --git a/feedcrunch_rssadmin/templates/admin/onboarding.html b/feedcrunch_rssadmin/templates/admin/onboarding.html index f4fb409..a250cc7 100644 --- a/feedcrunch_rssadmin/templates/admin/onboarding.html +++ b/feedcrunch_rssadmin/templates/admin/onboarding.html @@ -27,6 +27,7 @@ + @@ -34,11 +35,9 @@ - - @@ -100,6 +99,7 @@ +
@@ -108,6 +108,7 @@
  • Social Profiles
  • Personal Details
  • +
    @@ -146,6 +147,7 @@

    Learn

    +
    @@ -186,9 +188,13 @@

    Create Opportunities

    @@ -209,8 +215,16 @@

    Create Opportunities

    @@ -230,8 +244,16 @@

    Create Opportunities

    @@ -239,7 +261,7 @@

    Create Opportunities

    - +
    +
    -
    -
    + +
    • @@ -373,20 +396,23 @@

      Create Opportunities

    -
    +
    + + - + + diff --git a/feedcrunch_rssadmin/views.py b/feedcrunch_rssadmin/views.py index 7964f47..4a7e90b 100644 --- a/feedcrunch_rssadmin/views.py +++ b/feedcrunch_rssadmin/views.py @@ -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):