From dbf3d1f41b73df2caecb5941dd3f0a72226e22c6 Mon Sep 17 00:00:00 2001 From: Filipe Ximenes Date: Mon, 22 May 2017 15:45:17 -0400 Subject: [PATCH 1/3] adds speakers view --- .gitignore | 2 ++ pybay/templates/frontend/speakers_list.html | 23 +++++++++++++++++++++ pybay/urls.py | 5 ++++- pybay/views.py | 18 ++++++++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 pybay/templates/frontend/speakers_list.html diff --git a/.gitignore b/.gitignore index 6c1419f7..3bf785bb 100644 --- a/.gitignore +++ b/.gitignore @@ -89,3 +89,5 @@ ENV/ .ropeproject dev.db + +pybay/site_media/* \ No newline at end of file diff --git a/pybay/templates/frontend/speakers_list.html b/pybay/templates/frontend/speakers_list.html new file mode 100644 index 00000000..e445e401 --- /dev/null +++ b/pybay/templates/frontend/speakers_list.html @@ -0,0 +1,23 @@ +{% extends 'frontend/base.html' %} +{% load static %} +{% load thumbnail %} + +{% block content %} +
+
+
+ +
+ + {% for speaker in speakers %} +
+ {{ speaker.name }} +

{{ speaker.name }}

+ {{ speaker.biography|truncatechars:"300" }} +
+ {% endfor %} +
+
+{% endblock content %} diff --git a/pybay/urls.py b/pybay/urls.py index b5db8d4c..f3c5d19f 100644 --- a/pybay/urls.py +++ b/pybay/urls.py @@ -12,7 +12,9 @@ from symposion.sponsorship import urls as sponsor_urls from symposion.speakers import urls as speaker_urls -from pybay.views import pybay_cfp_create, pybay_sponsors_list, pybay_faq_index +from pybay.views import ( + pybay_cfp_create, pybay_sponsors_list, + pybay_faq_index, pybay_speakers_list) WIKI_SLUG = r"(([\w-]{2,})(/[\w-]{2,})*)" @@ -45,6 +47,7 @@ # url(r"^teams/", include("symposion.teams.urls")), # url(r"^markitup/", include("markitup.urls")), url(r"^our-sponsors$", pybay_sponsors_list, name="pybay_sponsors_list"), + url(r"^our-speakers$", pybay_speakers_list, name="pybay_speakers_list"), # url(r"^", include("symposion.cms.urls")), ] diff --git a/pybay/views.py b/pybay/views.py index fdccb7d4..6f4eb00a 100644 --- a/pybay/views.py +++ b/pybay/views.py @@ -3,6 +3,7 @@ from .forms import CallForProposalForm from pybay.faqs.models import Faq from symposion.sponsorship.models import Sponsor +from pybay.proposals.models import Proposal from collections import defaultdict @@ -44,3 +45,20 @@ def pybay_cfp_create(request): else: form = CallForProposalForm() return render(request, 'frontend/cfp.html', {'form': form}) + + +def pybay_speakers_list(request): + accepted_proposals = Proposal.objects.filter( + result__status='accepted') + speakers = [] + for proposal in accepted_proposals: + speakers.append(proposal.speaker) + speakers += proposal.additional_speakers.all() + + speakers = list(set(speakers)) # filters duplicate speakers + speakers = filter(lambda s: s.photo, speakers) # removes speakers without photo + speakers = sorted(speakers, key=lambda i: i.name) # sorts alphabetically + + return render(request, 'frontend/speakers_list.html', { + 'speakers': speakers + }) From 75eb1dc08d7c12487899ad31638926fb7532e4eb Mon Sep 17 00:00:00 2001 From: Filipe Ximenes Date: Mon, 22 May 2017 17:32:43 -0400 Subject: [PATCH 2/3] adds link to speakers list page to the navbar --- pybay/context_processors.py | 7 +++++++ pybay/settings.py | 9 +++++++-- pybay/templates/frontend/base.html | 7 ++++++- pybay/templates/frontend/speakers_list.html | 2 +- pybay/tests.py | 5 ++--- pybay/views.py | 2 +- 6 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 pybay/context_processors.py diff --git a/pybay/context_processors.py b/pybay/context_processors.py new file mode 100644 index 00000000..21636c94 --- /dev/null +++ b/pybay/context_processors.py @@ -0,0 +1,7 @@ +from django.conf import settings + + +def settings_variables(request): + return { + 'SHOW_SPEAKERS_LIST_NAVBAR_LINK': getattr(settings, 'SHOW_SPEAKERS_LIST_NAVBAR_LINK', False) + } diff --git a/pybay/settings.py b/pybay/settings.py index a9e63013..4bb1f74b 100644 --- a/pybay/settings.py +++ b/pybay/settings.py @@ -92,7 +92,10 @@ 'django.contrib.messages.context_processors.messages', 'account.context_processors.account', 'pinax_theme_bootstrap.context_processors.theme', - 'symposion.reviews.context_processors.reviews']}}] + 'symposion.reviews.context_processors.reviews', + 'pybay.context_processors.settings_variables', + ]} +}] MIDDLEWARE_CLASSES = [ "django.contrib.sessions.middleware.SessionMiddleware", @@ -217,4 +220,6 @@ "talk": "pybay.proposals.forms.TalkProposalForm", } #Crispy Forms -CRISPY_TEMPLATE_PACK ='bootstrap3' +CRISPY_TEMPLATE_PACK = 'bootstrap3' + +SHOW_SPEAKERS_LIST_NAVBAR_LINK = True diff --git a/pybay/templates/frontend/base.html b/pybay/templates/frontend/base.html index 4e7a51e5..f9230a8e 100644 --- a/pybay/templates/frontend/base.html +++ b/pybay/templates/frontend/base.html @@ -55,8 +55,13 @@ sponsors
  • - call for proposals + Call For Proposals
  • + {% if SHOW_SPEAKERS_LIST_NAVBAR_LINK %} +
  • + Speakers +
  • + {% endif %}
  • Registration
  • diff --git a/pybay/templates/frontend/speakers_list.html b/pybay/templates/frontend/speakers_list.html index e445e401..27ade3f7 100644 --- a/pybay/templates/frontend/speakers_list.html +++ b/pybay/templates/frontend/speakers_list.html @@ -13,7 +13,7 @@

    All Speakers

    {% for speaker in speakers %}
    - {{ speaker.name }} + {{ speaker.name }}

    {{ speaker.name }}

    {{ speaker.biography|truncatechars:"300" }}
    diff --git a/pybay/tests.py b/pybay/tests.py index 0ec2cebe..c71531fd 100644 --- a/pybay/tests.py +++ b/pybay/tests.py @@ -2,13 +2,12 @@ from pybay.forms import CallForProposalForm - class CfpFormTestCase(TestCase): - fixtures=[ + fixtures = [ "conference", "proposal_base", ] - + def _get_data(self): return { 'first_name': "Daniel", diff --git a/pybay/views.py b/pybay/views.py index 6f4eb00a..666e9765 100644 --- a/pybay/views.py +++ b/pybay/views.py @@ -56,7 +56,7 @@ def pybay_speakers_list(request): speakers += proposal.additional_speakers.all() speakers = list(set(speakers)) # filters duplicate speakers - speakers = filter(lambda s: s.photo, speakers) # removes speakers without photo + speakers = filter(lambda s: s.photo, speakers) # filters speakers without photo speakers = sorted(speakers, key=lambda i: i.name) # sorts alphabetically return render(request, 'frontend/speakers_list.html', { From f8ed0aa9424b937d55edc5b964287ce09a51b25f Mon Sep 17 00:00:00 2001 From: Filipe Ximenes Date: Mon, 22 May 2017 18:07:34 -0400 Subject: [PATCH 3/3] uses proposal speakers method to fetch all speakers --- pybay/templates/frontend/speakers_list.html | 2 +- pybay/tests/__init__.py | 0 pybay/{tests.py => tests/test_forms.py} | 0 pybay/views.py | 3 +-- requirements.txt | 8 ++++---- 5 files changed, 6 insertions(+), 7 deletions(-) create mode 100644 pybay/tests/__init__.py rename pybay/{tests.py => tests/test_forms.py} (100%) diff --git a/pybay/templates/frontend/speakers_list.html b/pybay/templates/frontend/speakers_list.html index 27ade3f7..65ab68c1 100644 --- a/pybay/templates/frontend/speakers_list.html +++ b/pybay/templates/frontend/speakers_list.html @@ -10,7 +10,7 @@

    All Speakers

    - + {% for speaker in speakers %}
    {{ speaker.name }} diff --git a/pybay/tests/__init__.py b/pybay/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pybay/tests.py b/pybay/tests/test_forms.py similarity index 100% rename from pybay/tests.py rename to pybay/tests/test_forms.py diff --git a/pybay/views.py b/pybay/views.py index 666e9765..f9630292 100644 --- a/pybay/views.py +++ b/pybay/views.py @@ -52,8 +52,7 @@ def pybay_speakers_list(request): result__status='accepted') speakers = [] for proposal in accepted_proposals: - speakers.append(proposal.speaker) - speakers += proposal.additional_speakers.all() + speakers += list(proposal.speakers()) speakers = list(set(speakers)) # filters duplicate speakers speakers = filter(lambda s: s.photo, speakers) # filters speakers without photo diff --git a/requirements.txt b/requirements.txt index 2186e735..81e98b62 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ -Django==1.9.2 django-appconf==1.0.1 django-bootstrap-form==3.2.1 +django-crispy-forms==1.6.1 django-jsonfield==1.0.1 django-markitup==2.2.2 django-model-utils==2.4 @@ -10,16 +10,16 @@ django-taggit==0.18.0 django-timezone-field==2.0 django-timezones==0.2 django-user-accounts==2.0 +Django==1.9.2 easy-thumbnails==2.3 eventlog==0.8.0 +git+https://github.com/pybay/symposion.git#egg=symposion-1.0b2.dev3 html5lib==0.9999999 Markdown==2.6.5 metron==1.3.5 olefile==0.44 -git+https://github.com/pybay/symposion.git#egg=symposion-1.0b2.dev3 Pillow +pinax-boxes==2.1.2 pinax-theme-bootstrap==5.6.0 pytz==2015.7 six==1.10.0 -pinax-boxes==2.1.2 -django-crispy-forms==1.6.1