From 0858449b3f7211829ef347bc1dd141b5bca5f8cb Mon Sep 17 00:00:00 2001 From: Michael Hall Date: Mon, 30 Apr 2018 23:53:54 -0400 Subject: [PATCH] Add LinkedIn sharing, add user help for creating a new talk, fix some permissions around approving presentations --- get_together/settings.py | 16 ++++++++++++++- get_together/static/css/get_together.css | 11 +++++++++- .../get_together/events/show_event.html | 20 ++++++++++++++++++- .../speakers/list_user_presentations.html | 4 ++++ .../templates/get_together/users/login.html | 1 + get_together/views/speakers.py | 11 +++++++++- 6 files changed, 59 insertions(+), 4 deletions(-) diff --git a/get_together/settings.py b/get_together/settings.py index 83146c0..5a2a50d 100644 --- a/get_together/settings.py +++ b/get_together/settings.py @@ -66,7 +66,7 @@ AUTHENTICATION_BACKENDS = ( 'social_core.backends.github.GithubOAuth2', 'social_core.backends.twitter.TwitterOAuth', 'social_core.backends.facebook.FacebookOAuth2', - 'social_core.backends.yahoo.YahooOpenId', +# 'social_core.backends.linkedin.LinkedinOAuth2', ) MIDDLEWARE = [ @@ -163,7 +163,20 @@ GOOGLE_MAPS_API_KEY=None SOCIAL_AUTH_GITHUB_KEY=None SOCIAL_AUTH_GOOGLE_OAUTH2_KEY=None SOCIAL_AUTH_FACEBOOK_KEY=None +SOCIAL_AUTH_FACEBOOK_SCOPE = ['email'] +SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = { + 'fields': 'id, name, email' +} +SOCIAL_AUTH_FACEBOOK_API_VERSION = '2.12' SOCIAL_AUTH_TWITTER_KEY=None +SOCIAL_AUTH_LINKEDIN_KEY=None +SOCIAL_AUTH_LINKEDIN_SECRET=None +SOCIAL_AUTH_LINKEDIN_SCOPE = ['r_basicprofile', 'r_emailaddress'] +SOCIAL_AUTH_LINKEDIN_FIELD_SELECTORS = ['email-address'] +SOCIAL_AUTH_LINKEDIN_EXTRA_DATA = [('id', 'id'), + ('firstName', 'first_name'), + ('lastName', 'last_name'), + ('emailAddress', 'email_address')] SETTINGS_EXPORT = [ 'DEBUG', 'GOOGLE_ANALYTICS_ID', @@ -172,6 +185,7 @@ SETTINGS_EXPORT = [ 'SOCIAL_AUTH_GOOGLE_OAUTH2_KEY', 'SOCIAL_AUTH_FACEBOOK_KEY', 'SOCIAL_AUTH_TWITTER_KEY', + 'SOCIAL_AUTH_LINKEDIN_KEY', ] # Make django messages framework use Bootstrap's alert style classes diff --git a/get_together/static/css/get_together.css b/get_together/static/css/get_together.css index e032615..a0b86b6 100644 --- a/get_together/static/css/get_together.css +++ b/get_together/static/css/get_together.css @@ -32,7 +32,7 @@ form { display: inline; } .ui-selectmenu-menu .ui-menu { - height: 200px; + max-height: 200px; } .gt_lookup .ui-selectmenu-icon.ui-icon { background-position: 0px 0px; @@ -77,6 +77,15 @@ form { color: #FFFFFF; } +.btn-linkedin { + color: #FFFFFF; + background-color: #0084bf; + border-color: #0084bf; +} +.btn-linkedin:hover, .btn-linkedin:active { + color: #FFFFFF; +} + ul.errorlist li { padding: 0.75rem 1.25rem; margin-bottom: 1rem; diff --git a/get_together/templates/get_together/events/show_event.html b/get_together/templates/get_together/events/show_event.html index 846ff9f..6c5f069 100644 --- a/get_together/templates/get_together/events/show_event.html +++ b/get_together/templates/get_together/events/show_event.html @@ -78,6 +78,21 @@ }(document, "script", "twitter-wjs")); {% endif %} +{% if settings.SOCIAL_AUTH_LINKEDIN_KEY %} + +{% endif %} {% endblock %} {% block content %} @@ -104,6 +119,9 @@ {% if settings.SOCIAL_AUTH_FACEBOOK_KEY %} Share {% endif %} + {% if settings.SOCIAL_AUTH_LINKEDIN_KEY %} + Share + {% endif %} {% if not is_attending %} Attend {% endif %} @@ -155,7 +173,7 @@
{{presentation.talk.title}} by {{presentation.talk.speaker.user}}, {{presentation.talk.speaker.title}}
{% endfor %} Propose a talk - {% if pending_presentations %} + {% if pending_presentations and can_edit_event %} {{pending_presentations}} proposed talks {% endif %} diff --git a/get_together/templates/get_together/speakers/list_user_presentations.html b/get_together/templates/get_together/speakers/list_user_presentations.html index fe4dd21..96b466e 100644 --- a/get_together/templates/get_together/speakers/list_user_presentations.html +++ b/get_together/templates/get_together/speakers/list_user_presentations.html @@ -8,6 +8,10 @@ {% block content %}
+{% if not has_talks %} +
You must create a talk before it can be proposed to this event.
+{% endif %} + {% if proposed_talks %}
{% for presentation in proposed_talks %} diff --git a/get_together/templates/get_together/users/login.html b/get_together/templates/get_together/users/login.html index 8482eea..fdae9cf 100644 --- a/get_together/templates/get_together/users/login.html +++ b/get_together/templates/get_together/users/login.html @@ -10,6 +10,7 @@ {% if settings.SOCIAL_AUTH_GOOGLE_OAUTH2_KEY %} Google{% endif %} {% if settings.SOCIAL_AUTH_FACEBOOK_KEY %} Faceboook{% endif %} {% if settings.SOCIAL_AUTH_TWITTER_KEY %} Twitter{% endif %} + {% comment %}{% if settings.SOCIAL_AUTH_LINKEDIN_KEY %} LinkedIn{% endif %}{% endcomment %} {% if settings.SOCIAL_AUTH_GITHUB_KEY %} GitHub{% endif %}
Note: The only information GetTogether recieves from these providers is your username and (optionally) your email address. GetTogether will not have access to read any other information from these accounts, not even your password, and will not have access to post information to them.
diff --git a/get_together/views/speakers.py b/get_together/views/speakers.py index 217badd..adccacc 100644 --- a/get_together/views/speakers.py +++ b/get_together/views/speakers.py @@ -126,6 +126,10 @@ def show_talk(request, talk_id): return render(request, 'get_together/speakers/show_talk.html', context) def add_talk(request): + if Speaker.objects.filter(user=request.user.profile).count() < 1: + messages.add_message(request, messages.WARNING, message=_('You must create a new Speaker profile before you can add a talk')) + return redirect('add-speaker') + new_talk = Talk() if request.method == 'GET': talk_form = UserTalkForm(instance=new_talk) @@ -226,13 +230,15 @@ def propose_event_talk(request, event_id): if request.method == 'GET': profile = request.user.profile talks = list(Talk.objects.filter(speaker__user=profile)) - presentations = event.presentations.all().order_by('-status') + has_talks = len(talks) > 0 + presentations = event.presentations.filter(talk__speaker__user=profile).order_by('-status') for presentation in presentations: if presentation.talk in talks: talks.remove(presentation.talk) context = { 'event': event, + 'has_talks': has_talks, 'available_talks': talks, 'proposed_talks': presentations, } @@ -253,6 +259,9 @@ def propose_event_talk(request, event_id): def schedule_event_talks(request, event_id): event = get_object_or_404(Event, id=event_id) + if not request.user.profile.can_edit_event(event): + messages.add_message(request, messages.ERROR, message=mark_safe(_('You can not manage talks for this event.'))) + return redirect(event.get_absolute_url()) if not event.team.is_premium: messages.add_message(request, messages.ERROR, message=mark_safe(_('Upgrade this team to a Premium account to use this feature.'))) return redirect(event.get_absolute_url())