From 6dd34f71c19c896c33746c43efb3a2f90747582e Mon Sep 17 00:00:00 2001 From: Tlazypanda Date: Fri, 9 Nov 2018 22:34:06 +0530 Subject: [PATCH] End date and time added to forms and displayed --- systers_portal/meetup/forms.py | 6 ++++-- systers_portal/meetup/models.py | 6 +++--- systers_portal/meetup/tests/test_views.py | 7 +++---- systers_portal/templates/meetup/meetup.html | 12 +++++++++--- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/systers_portal/meetup/forms.py b/systers_portal/meetup/forms.py index 91ff23d2..d2350269 100644 --- a/systers_portal/meetup/forms.py +++ b/systers_portal/meetup/forms.py @@ -91,9 +91,11 @@ class AddMeetupForm(ModelFormWithHelper): """ class Meta: model = Meetup - fields = ('title', 'slug', 'date', 'time', 'venue', 'description') + fields = ('title', 'slug', 'date', 'end_date', 'time', 'end_time', 'venue', 'description') widgets = {'date': forms.DateInput(attrs={'type': 'text', 'class': 'datepicker'}), - 'time': forms.TimeInput(attrs={'type': 'text', 'class': 'timepicker'})} + 'end_date': forms.DateInput(attrs={'type': 'text', 'class': 'datepicker'}), + 'time': forms.TimeInput(attrs={'type': 'text', 'class': 'timepicker'}), + 'end_time': forms.TimeInput(attrs={'type': 'text', 'class': 'timepicker'})} helper_class = SubmitCancelFormHelper helper_cancel_href = "{% url 'about_meetup_location' meetup_location.slug %}" diff --git a/systers_portal/meetup/models.py b/systers_portal/meetup/models.py index 908ef424..9fd6f64c 100644 --- a/systers_portal/meetup/models.py +++ b/systers_portal/meetup/models.py @@ -92,9 +92,9 @@ class Meetup(models.Model): title = models.CharField(max_length=50, verbose_name="Title",) slug = models.SlugField(max_length=50, unique=True, verbose_name="Slug") date = models.DateField(verbose_name="Date") - end_date = models.DateField(verbose_name="End Date", null=True) - time = models.TimeField(verbose_name="Time", blank=True) - end_time = models.TimeField(verbose_name="End Time", null=True) + end_date = models.DateField(verbose_name="End Date", blank=True) + time = models.TimeField(verbose_name="Time") + end_time = models.TimeField(verbose_name="End Time", blank=True) venue = models.CharField(max_length=512, verbose_name="Venue", blank=True) description = models.TextField(verbose_name="Description") meetup_location = models.ForeignKey(MeetupLocation, verbose_name="Meetup Location") diff --git a/systers_portal/meetup/tests/test_views.py b/systers_portal/meetup/tests/test_views.py index 7f3c356b..33da6890 100644 --- a/systers_portal/meetup/tests/test_views.py +++ b/systers_portal/meetup/tests/test_views.py @@ -2008,8 +2008,7 @@ def test_post_view(self): 'distance': '', 'unit': ''}]}) - data1 = {'date': '2018-06-13', 'meeetup_location': 'Foo Systers1', 'keyword': 'test', - 'filter': 'distance'} + data1 = {'date': '2018-06-13', 'meeetup_location': 'Foo Systers1', 'keyword': 'test'} response = self.client.post(url, data1, format='json') self.assertEqual(json.loads(response.content.decode('utf-8')), {'search_results': @@ -2018,8 +2017,8 @@ def test_post_view(self): 'location': 'Foo Systers1', 'location_slug': 'foob', 'meetup_slug': 'foobarbaz', - 'distance': 2800, - 'unit': 'kilometers from your location'}]}) + 'distance': '', + 'unit': ''}]}) data2 = {'date': '2018-06-12', 'meeetup_location': 'Meetup Location'} response = self.client.post(url, data2, format='json') diff --git a/systers_portal/templates/meetup/meetup.html b/systers_portal/templates/meetup/meetup.html index 28bb404f..f5bdb0e0 100644 --- a/systers_portal/templates/meetup/meetup.html +++ b/systers_portal/templates/meetup/meetup.html @@ -3,10 +3,16 @@ {% block meetup_location_page_content %}

{{ meetup.title }}

-

+

Date: {{ meetup.date }} -     + {% if meetup.end_date %} + EndDate: {{ meetup.end_date }} + {% endif %} +     Time: {{ meetup.time|time:"H:i" }} + {% if meetup.end_time %} + Time: {{ meetup.end_time|time:"H:i" }} + {% endif %}

Venue: {{ meetup.venue }} @@ -27,7 +33,7 @@

{{ meetup.title }}

{{ not_coming_no }} - +
{% include 'meetup/snippets/share_buttons.html' %}