From aa50e85b9a737f9e8923ad790636fe4ac9bb1a49 Mon Sep 17 00:00:00 2001 From: Michael Hall Date: Mon, 12 Feb 2018 19:32:42 -0200 Subject: [PATCH] Add support for login and sharing with Facebook and Twitter if app keys are defined --- events/models/events.py | 4 + get_together/settings.py | 4 + get_together/templates/get_together/base.html | 4 +- .../get_together/events/share_event.html | 84 +++++++++++++++++++ .../get_together/events/show_event.html | 15 +++- .../templates/get_together/index.html | 4 +- .../get_together/places/create_place.html | 2 +- get_together/urls.py | 1 + get_together/views/events.py | 9 +- 9 files changed, 122 insertions(+), 5 deletions(-) create mode 100644 get_together/templates/get_together/events/share_event.html diff --git a/events/models/events.py b/events/models/events.py index 29f1a57..2f76ba6 100644 --- a/events/models/events.py +++ b/events/models/events.py @@ -73,6 +73,10 @@ class Event(models.Model): def get_absolute_url(self): return reverse('show-event', kwargs={'event_id': self.id, 'event_slug': self.slug}) + def get_full_url(self): + site = Site.objects.get(id=1) + return "https://%s%s" % (site.domain, self.get_absolute_url()) + @property def slug(self): return slugify(self.name) diff --git a/get_together/settings.py b/get_together/settings.py index 3231316..425564b 100644 --- a/get_together/settings.py +++ b/get_together/settings.py @@ -151,12 +151,16 @@ GOOGLE_ANALYTICS_ID=None GOOGLE_MAPS_API_KEY=None SOCIAL_AUTH_GITHUB_KEY=None SOCIAL_AUTH_GOOGLE_OAUTH2_KEY=None +SOCIAL_AUTH_FACEBOOK_KEY=None +SOCIAL_AUTH_TWITTER_KEY=None SETTINGS_EXPORT = [ 'DEBUG', 'GOOGLE_ANALYTICS_ID', 'GOOGLE_MAPS_API_KEY', 'SOCIAL_AUTH_GITHUB_KEY', 'SOCIAL_AUTH_GOOGLE_OAUTH2_KEY', + 'SOCIAL_AUTH_FACEBOOK_KEY', + 'SOCIAL_AUTH_TWITTER_KEY', ] # Make django messages framework use Bootstrap's alert style classes diff --git a/get_together/templates/get_together/base.html b/get_together/templates/get_together/base.html index 3bfcefa..170fe72 100644 --- a/get_together/templates/get_together/base.html +++ b/get_together/templates/get_together/base.html @@ -6,7 +6,9 @@ - Get Together + {% block title %}Get Together{% block add_to_title %}{% endblock %}{% endblock %} + + {% block meta %}{% endblock %} {% if settings.GOOGLE_ANALYTICS_ID %} diff --git a/get_together/templates/get_together/events/share_event.html b/get_together/templates/get_together/events/share_event.html new file mode 100644 index 0000000..89f8e3c --- /dev/null +++ b/get_together/templates/get_together/events/share_event.html @@ -0,0 +1,84 @@ +{% extends "get_together/base.html" %} +{% load static %} + +{% block add_to_totle %} | {{event.name}}{% endblock %} + +{% block meta %} + + + + + + +{% endblock %} + +{% block content %} +{% if settings.SOCIAL_AUTH_FACEBOOK_KEY %} + +{% endif %} +{% if settings.SOCIAL_AUTH_TWITTER_KEY %} + +{% endif %} + +

Announce your Get Together

+
+
+
+ {% if settings.SOCIAL_AUTH_FACEBOOK_KEY %}Facebook{% endif %} + {% if settings.SOCIAL_AUTH_TWITTER_KEY %} + + Twitter + {% endif %} +
+ +
+
+{% endblock %} diff --git a/get_together/templates/get_together/events/show_event.html b/get_together/templates/get_together/events/show_event.html index 45bfc9b..85fe4a9 100644 --- a/get_together/templates/get_together/events/show_event.html +++ b/get_together/templates/get_together/events/show_event.html @@ -1,5 +1,15 @@ {% extends "get_together/base.html" %} -{% load markup %} +{% load markup static %} + +{% block add_to_totle %} | {{event.name}}{% endblock %} + +{% block meta %} + + + + + +{% endblock %} {% block styles %}