-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a new form to send events to the mailing list. Co-Authored-By: Mario Corchero <mariocj89@gmail.com> Co-Authored-By: Alex Chamberlain <alex@alexchamberlain.co.uk> Fixes #1168
- Loading branch information
1 parent
29ccc8a
commit eaece78
Showing
15 changed files
with
343 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.5 on 2017-11-01 21:38 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations | ||
|
||
|
||
def migrate_old_content(apps, schema_editor): | ||
Box = apps.get_model('boxes', 'Box') | ||
Box.objects.filter(label='events-subscriptions').update(content= | ||
'<h2 class=\"widget-title\">Python Events Calendars</h2>\r\n\r\n<br/>\r\n\r\n' | ||
'<p>For Python events near you, please have a look at the <a href=\"http://lmorillas.github.io/python_events/\">' | ||
'<b>Python events map</b></a>.</p>\r\n\r\n' | ||
'<p>The Python events calendars are maintained by the <a href=\"https://wiki.python.org/moin/PythonEventsCalendar#Python_Calendar_Team\">events calendar team</a>.</p>\r\n\r\n' | ||
'<p>Please see the <a href=\"https://wiki.python.org/moin/PythonEventsCalendar\">' | ||
'events calendar project page</a> for details on how to <a href=\"/events/submit/\">submit events</a>,' | ||
'<a href=\"https://wiki.python.org/moin/PythonEventsCalendar#Available_Calendars\">subscribe to the calendars</a>,' | ||
'get <a href=\"https://twitter.com/PythonEvents\">Twitter feeds</a> or embed them.</p>\r\n\r\n<p>Thank you.</p>\r\n' | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('boxes', '0002_auto_20150416_1853'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(migrate_old_content), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from django import forms | ||
|
||
from django.conf import settings | ||
from django.contrib.sites.models import Site | ||
from django.core.mail import send_mail | ||
|
||
from django.template import loader | ||
|
||
|
||
def set_placeholder(value): | ||
return forms.TextInput(attrs={'placeholder': value, 'required': 'required'}) | ||
|
||
|
||
class EventForm(forms.Form): | ||
event_name = forms.CharField(widget=set_placeholder( | ||
'Name of the event (including the user group name for ' | ||
'user group events)' | ||
)) | ||
event_type = forms.CharField(widget=set_placeholder( | ||
'conference, bar camp, sprint, user group meeting, etc.' | ||
)) | ||
python_focus = forms.CharField(widget=set_placeholder( | ||
'Data analytics, Web Development, Country-wide conference, etc...' | ||
)) | ||
expected_attendees = forms.CharField(widget=set_placeholder('300+')) | ||
location = forms.CharField(widget=set_placeholder( | ||
'IFEMA building, Madrid, Spain' | ||
)) | ||
date_from = forms.DateField(widget=forms.SelectDateWidget()) | ||
date_to = forms.DateField(widget=forms.SelectDateWidget()) | ||
recurrence = forms.CharField(widget=set_placeholder( | ||
'None, every second Thursday, monthly, etc.' | ||
)) | ||
link = forms.URLField(label='Website URL') | ||
description = forms.CharField(widget=forms.Textarea) | ||
|
||
def send_email(self, creator): | ||
context = { | ||
'event': self.cleaned_data, | ||
'creator': creator, | ||
'site': Site.objects.get_current(), | ||
} | ||
text_message_template = loader.get_template('events/email/new_event.txt') | ||
text_message = text_message_template.render(context) | ||
send_mail( | ||
subject='New event submission: "{}"'.format(self.cleaned_data['event_name']), | ||
message=text_message, | ||
from_email=creator.email, | ||
recipient_list=[settings.EVENTS_TO_EMAIL], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import datetime | ||
|
||
from django.test import SimpleTestCase | ||
|
||
from ..forms import EventForm | ||
|
||
|
||
class EventFormTests(SimpleTestCase): | ||
|
||
def test_valid_form(self): | ||
data = { | ||
'event_name': 'PyConES17', | ||
'event_type': 'conference', | ||
'python_focus': 'Country-wide conference', | ||
'expected_attendees': '500', | ||
'location': 'Complejo San Francisco, Caceres, Spain', | ||
'date_from': datetime.datetime(2017, 9, 22), | ||
'date_to': datetime.datetime(2017, 9, 25), | ||
'recurrence': 'None', | ||
'link': 'https://2017.es.pycon.org/en/', | ||
'description': 'A conference no one can afford to miss', | ||
} | ||
form = EventForm(data=data) | ||
self.assertTrue(form.is_valid(), form.errors) | ||
self.assertEqual(form.errors, {}) | ||
|
||
def test_invalid_form(self): | ||
data = { | ||
'event_name': 'PyConES17', | ||
'event_type': 'conference', | ||
'python_focus': 'Country-wide conference', | ||
'expected_attendees': '500', | ||
'location': 'Complejo San Francisco, Caceres, Spain', | ||
'date_to': datetime.datetime(2017, 9, 25), | ||
'recurrence': 'None', | ||
'link': 'https://2017.es.pycon.org/en/', | ||
'description': 'A conference no one can afford to miss', | ||
} | ||
form = EventForm(data=data) | ||
self.assertFalse(form.is_valid(), form.errors) | ||
self.assertEqual( | ||
form.errors, | ||
{'date_from': ['This field is required.']} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{% extends "base.html" %} | ||
{% load boxes %} | ||
|
||
{% block content_attributes %}with-right-sidebar{% endblock %} | ||
|
||
{% block right_sidebar %} | ||
<aside class="right-sidebar" role="secondary"> | ||
<div class="sidebar-widget subscribe-widget"> | ||
{% if calendar %} | ||
<h2 class="widget-title">Python Event Subscriptions</h2> | ||
<p>Subscribe to Python Event Calendars:</p> | ||
<ul class="menu"> | ||
{% if calendar.embed %}<li><a href="{{ calendar.embed }}"><span aria-hidden="true" class="icon-embed"></span>Embeddable widget</a></li>{% endif %} | ||
{% if calendar.rss %}<li><a href="{{ calendar.rss }}"><span aria-hidden="true" class="icon-feed"></span>Events via RSS</a></li>{% endif %} | ||
{% if calendar.url %}<li><a href="{{ calendar.url }}"><span aria-hidden="true" class="icon-ical"></span>Events in iCal format</a></li>{% endif %} | ||
{% if calendar.twitter %}<li><a href="{{ calendar.twitter }}"><span aria-hidden="true" class="icon-twitter"></span>Events on Twitter</a></li>{% endif %} | ||
</ul> | ||
{% endif %} | ||
{% box 'events-subscriptions' %} | ||
</div> | ||
|
||
{% if event_categories %} | ||
<div class="sidebar-widget eventtypes-widget"> | ||
<h2 class="widget-title">Event Categories</h2> | ||
<p class="give-me-more"><a href="#" title="More Event Categories">More</a></p> | ||
<ul class="menu"> | ||
{% for category in event_categories %} | ||
<li><a href="{{ category.get_absolute_url }}">{{ category.name }}</a></li> | ||
{% endfor %} | ||
<li><a class="readmore" href="{% url 'events:eventcategory_list' calendar_slug=view.kwargs.calendar_slug %}">More Types</a></li> | ||
</ul> | ||
</div> | ||
{% endif %} | ||
|
||
{% comment %} | ||
Less useful to look at and use than I thought they might be. | ||
Titles of locations are the whole address most times, and unless someone in the DB controlled the way they were written and presented, this might always be a mess | ||
{% if event_locations %} | ||
<div class="sidebar-widget authors-widget"> | ||
<h2 class="widget-title">Event Locations</h2> | ||
<p class="give-me-more"><a href="#" title="More Event Locations">More</a></p> | ||
<ul class="menu"> | ||
{% for location in event_locations %} | ||
<li><a href="{{ location.get_absolute_url }}">{{ location.name }}</a></li> | ||
{% endfor %} | ||
<li><a class="readmore" href="{% url 'events:eventlocation_list' calendar_slug=view.kwargs.calendar_slug %}">More Locations</a></li> | ||
</ul> | ||
</div> | ||
{% endif %} | ||
{% endcomment %} | ||
|
||
</aside> | ||
{% endblock right_sidebar %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
The following event was submitted for approval: | ||
|
||
Name: {{ event.event_name }} | ||
Type: {{ event.event_type }} | ||
Focus: {{ event.python_focus }} | ||
Approximate Number of Attendees: {{ event.expected_attendees }} | ||
Location: {{ event.location }} | ||
Date/Time: {{ event.date_from }} - {{ event.date_to }} | ||
Recurrence: {{ event.recurrence }} | ||
Link: <a href="{{ event.link }}">{{ event.event_name }}</a> | ||
|
||
Description: | ||
{{ event.description }} |
Oops, something went wrong.