diff --git a/events/forms.py b/events/forms.py index 18552a1..078a49a 100644 --- a/events/forms.py +++ b/events/forms.py @@ -184,9 +184,10 @@ class DeleteTeamForm(forms.Form): confirm = forms.BooleanField(label="Yes, delete team", required=True) class TeamEventForm(forms.ModelForm): + recurrences = recurrence.forms.RecurrenceField(label="Repeat", required=False) class Meta: model = Event - fields = ['name', 'start_time', 'end_time', 'summary', 'web_url', 'announce_url', 'tags'] + fields = ['name', 'start_time', 'end_time', 'recurrences', 'summary', 'web_url', 'announce_url', 'tags'] widgets = { 'place': Lookup(source=Place), 'start_time': DateTimeWidget, diff --git a/get_together/templates/get_together/events/edit_event.html b/get_together/templates/get_together/events/edit_event.html index 23a4b21..f6fefd5 100644 --- a/get_together/templates/get_together/events/edit_event.html +++ b/get_together/templates/get_together/events/edit_event.html @@ -1,6 +1,12 @@ {% extends "get_together/base.html" %} {% load static %} +{% block meta %} + + + +{% endblock %} + {% block content %}

Updating {{event.name}}

diff --git a/get_together/views/events.py b/get_together/views/events.py index 64fb18f..104f308 100644 --- a/get_together/views/events.py +++ b/get_together/views/events.py @@ -123,7 +123,8 @@ def create_event(request, team_id): new_series.save() new_event.series = new_series new_event.save() - messages.add_message(request, messages.SUCCESS, message=_('Your event has been scheduled! Next, find a place for your event.')) + + messages.add_message(request, messages.SUCCESS, message=_('Your event has been scheduled! Next, find a place for your event.')) return redirect('add-place', new_event.id) else: context = { @@ -240,6 +241,8 @@ def edit_event(request, event_id): if request.method == 'GET': form = TeamEventForm(instance=event) + if event.series is not None: + form.initial['recurrences'] = event.series.recurrences context = { 'team': event.team, @@ -251,6 +254,17 @@ def edit_event(request, event_id): form = TeamEventForm(request.POST,instance=event) if form.is_valid: new_event = form.save() + + if form.cleaned_data.get('recurrences', None): + if event.series is not None: + event.series.recurrences = form.cleaned_data['recurrences'] + event.series.save() + else: + new_series = EventSeries.from_event(new_event, recurrences=form.cleaned_data['recurrences']) + new_series.save() + new_event.series = new_series + new_event.save() + return redirect(new_event.get_absolute_url()) else: context = {