Add LinkedIn sharing, add user help for creating a new talk, fix some permissions around approving presentations

This commit is contained in:
Michael Hall 2018-04-30 23:53:54 -04:00
parent 4445a0d327
commit 0858449b3f
6 changed files with 59 additions and 4 deletions

View file

@ -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

View file

@ -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;

View file

@ -78,6 +78,21 @@
}(document, "script", "twitter-wjs"));
</script>
{% endif %}
{% if settings.SOCIAL_AUTH_LINKEDIN_KEY %}
<script type="text/javascript">
// Use the API call wrapper to share content on LinkedIn
function shareLinkedIn() {
//https://www.linkedin.com/cws/share?url=https%3A%2F%2Fdeveloper.linkedin.com%2Fetc%2Fdesigns%2Flinkedin%2Fkaty%2Fglobal%2Fclientlibs%2Fhtml%2Fsandbox.html%3Falign-class%3Dmiddle-center&original_referer=https%3A%2F%2Fdeveloper.linkedin.com%2Fetc%2Fdesigns%2Flinkedin%2Fkaty%2Fglobal%2Fclientlibs%2Fhtml%2Fsandbox.html%3Falign-class%3Dmiddle-center&token=&isFramed=true&lang=en_US&_ts=1525145063073.7769&xd_origin_host=https%3A%2F%2Fdeveloper.linkedin.com
// Build the JSON payload containing the content to be shared
window.open(
'https://www.linkedin.com/shareArticle?mini=true&url={{event.get_full_url|urlencode}}&summary={{event.name|urlencode}}&title=I\'m+having+a+Get+Together!&source=GetTogether.Community',
'_blank',
'height=300,width=400');
}
</script>{% endif %}
{% endblock %}
{% block content %}
@ -104,6 +119,9 @@
{% if settings.SOCIAL_AUTH_FACEBOOK_KEY %}
<a href="#" onClick="shareFacebook();" class="btn btn-facebook btn-sm"><i class="fa fa-facebook-official"></i> Share</a>
{% endif %}
{% if settings.SOCIAL_AUTH_LINKEDIN_KEY %}
<a href="#" onClick="shareLinkedIn();" class="IN-widget btn btn-linkedin btn-sm"><i class="fa fa-linkedin"></i> Share</a>
{% endif %}
{% if not is_attending %}
<a href="{% url 'attend-event' event.id %}" class="btn btn-success btn-sm"><i class="fa fa-check-square-o"></i> Attend</a>
{% endif %}
@ -155,7 +173,7 @@
<div><a href="{% url 'show-talk' presentation.talk.id %}">{{presentation.talk.title}}</a> by <a href="{% url 'show-speaker' presentation.talk.speaker.id %}">{{presentation.talk.speaker.user}}, {{presentation.talk.speaker.title}}</a></div>
{% endfor %}
<a class="btn btn-primary btn-sm" href="{% url 'propose-event-talk' event.id %}">Propose a talk</a>
{% if pending_presentations %}
{% if pending_presentations and can_edit_event %}
<a class="btn btn-success btn-sm" href="{% url 'schedule-event-talks' event.id %}">{{pending_presentations}} proposed talks</a>
{% endif %}
</td>

View file

@ -8,6 +8,10 @@
{% block content %}
<div class="container">
{% if not has_talks %}
<div class="alert alert-warning">You must create a talk before it can be proposed to this event.</div>
{% endif %}
{% if proposed_talks %}
<div class="row">
{% for presentation in proposed_talks %}

View file

@ -10,6 +10,7 @@
{% if settings.SOCIAL_AUTH_GOOGLE_OAUTH2_KEY %}<span><a class="btn btn-googleplus" href="{% url 'social:begin' 'google-oauth2' %}?{{ request.META.QUERY_STRING }}"><i class="fa fa-google-plus-official"></i> Google</a></span>{% endif %}
{% if settings.SOCIAL_AUTH_FACEBOOK_KEY %}<span><a class="btn btn-facebook" href="{% url 'social:begin' 'facebook' %}?{{ request.META.QUERY_STRING }}"><i class="fa fa-facebook-official"></i> Faceboook</a></span>{% endif %}
{% if settings.SOCIAL_AUTH_TWITTER_KEY %}<span><a class="btn btn-twitter" href="{% url 'social:begin' 'twitter' %}?{{ request.META.QUERY_STRING }}"><i class="fa fa-twitter"></i> Twitter</a></span>{% endif %}
{% comment %}{% if settings.SOCIAL_AUTH_LINKEDIN_KEY %}<span><a class="btn btn-linkedin" href="{% url 'social:begin' 'linkedin' %}?{{ request.META.QUERY_STRING }}"><i class="fa fa-linkedin"></i> LinkedIn</a></span>{% endif %}{% endcomment %}
{% if settings.SOCIAL_AUTH_GITHUB_KEY %}<span><a class="btn btn-github" href="{% url 'social:begin' 'github' %}?{{ request.META.QUERY_STRING }}"><i class="fa fa-github"></i> GitHub</a></span>{% endif %}
<div class="mt-2 alert alert-info"><small><b>Note:</b> 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. </small></div>
</center>

View file

@ -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 <a href="/about/premium">Premium</a> account to use this feature.')))
return redirect(event.get_absolute_url())