Add event toggles to enable/disable presentations, comments and photos. Fixes #109
This commit is contained in:
parent
50995b0a0f
commit
a1c387f520
6 changed files with 60 additions and 2 deletions
|
@ -225,7 +225,7 @@ class TeamEventForm(forms.ModelForm):
|
||||||
recurrences = recurrence.forms.RecurrenceField(label="Repeat", required=False)
|
recurrences = recurrence.forms.RecurrenceField(label="Repeat", required=False)
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Event
|
model = Event
|
||||||
fields = ['name', 'start_time', 'end_time', 'recurrences', 'summary', 'web_url', 'announce_url', 'tags']
|
fields = ['name', 'start_time', 'end_time', 'recurrences', 'summary', 'web_url', 'announce_url', 'enable_comments', 'enable_photos', 'enable_presentations']
|
||||||
widgets = {
|
widgets = {
|
||||||
'place': Lookup(source=Place),
|
'place': Lookup(source=Place),
|
||||||
'start_time': DateTimeWidget,
|
'start_time': DateTimeWidget,
|
||||||
|
@ -302,7 +302,13 @@ class NewEventDetailsForm(forms.ModelForm):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Event
|
model = Event
|
||||||
fields = ['summary', 'recurrences', 'web_url', 'announce_url']
|
fields = ['summary', 'recurrences', 'web_url', 'announce_url', 'enable_comments', 'enable_photos', 'enable_presentations']
|
||||||
|
|
||||||
|
|
||||||
|
class EventSettingsForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = Event
|
||||||
|
fields = ['enable_comments', 'enable_photos', 'enable_presentations']
|
||||||
|
|
||||||
|
|
||||||
class DeleteEventForm(forms.Form):
|
class DeleteEventForm(forms.Form):
|
||||||
|
|
28
events/migrations/0044_add_event_settings.py
Normal file
28
events/migrations/0044_add_event_settings.py
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# Generated by Django 2.0 on 2018-08-25 14:21
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('events', '0043_remove_premium_restrictions'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='event',
|
||||||
|
name='enable_comments',
|
||||||
|
field=models.BooleanField(default=True, verbose_name='Comments'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='event',
|
||||||
|
name='enable_photos',
|
||||||
|
field=models.BooleanField(default=True, verbose_name='Photos'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='event',
|
||||||
|
name='enable_presentations',
|
||||||
|
field=models.BooleanField(default=False, verbose_name='Presentations'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -93,6 +93,11 @@ class Event(models.Model):
|
||||||
|
|
||||||
sponsors = models.ManyToManyField('Sponsor', related_name='events', blank=True)
|
sponsors = models.ManyToManyField('Sponsor', related_name='events', blank=True)
|
||||||
|
|
||||||
|
enable_comments = models.BooleanField(verbose_name=_('Comments'), default=True)
|
||||||
|
enable_photos = models.BooleanField(verbose_name=_('Photos'), default=True)
|
||||||
|
enable_presentations = models.BooleanField(verbose_name=_('Presentations'), default=False)
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_over(self):
|
def is_over(self):
|
||||||
return self.end_time <= timezone.now()
|
return self.end_time <= timezone.now()
|
||||||
|
|
|
@ -210,6 +210,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if event.enable_presentations %}
|
||||||
<div class="row mb-2">
|
<div class="row mb-2">
|
||||||
<div class="col-3" width="120px"><b>Presentations:</b></div>
|
<div class="col-3" width="120px"><b>Presentations:</b></div>
|
||||||
<div class="col-9">
|
<div class="col-9">
|
||||||
|
@ -224,9 +225,11 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if event.enable_comments %}
|
||||||
<div class="container container-secondary mt-3">
|
<div class="container container-secondary mt-3">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col"><h4>Comments</h4></div>
|
<div class="col"><h4>Comments</h4></div>
|
||||||
|
@ -270,6 +273,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
|
@ -335,6 +339,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
{% if event.enable_photos %}
|
||||||
<div class="container container-secondary mb-3">
|
<div class="container container-secondary mb-3">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col"><h4>Photos</h4></div>
|
<div class="col"><h4>Photos</h4></div>
|
||||||
|
@ -362,6 +367,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -476,6 +476,10 @@ def attended_event(request, event_id):
|
||||||
|
|
||||||
def comment_event(request, event_id):
|
def comment_event(request, event_id):
|
||||||
event = Event.objects.get(id=event_id)
|
event = Event.objects.get(id=event_id)
|
||||||
|
if not event.enable_comments:
|
||||||
|
messages.add_message(request, messages.WARNING, message=_('This event does not allow comments.'))
|
||||||
|
return redirect(event.get_absolute_url())
|
||||||
|
|
||||||
if request.user.is_anonymous:
|
if request.user.is_anonymous:
|
||||||
messages.add_message(request, messages.WARNING, message=_("You must be logged in to comment."))
|
messages.add_message(request, messages.WARNING, message=_("You must be logged in to comment."))
|
||||||
return redirect(event.get_absolute_url())
|
return redirect(event.get_absolute_url())
|
||||||
|
@ -526,6 +530,10 @@ def add_event_photo(request, event_id):
|
||||||
messages.add_message(request, messages.WARNING, message=_('You can not make changes to this event.'))
|
messages.add_message(request, messages.WARNING, message=_('You can not make changes to this event.'))
|
||||||
return redirect(event.get_absolute_url())
|
return redirect(event.get_absolute_url())
|
||||||
|
|
||||||
|
if not event.enable_photos:
|
||||||
|
messages.add_message(request, messages.WARNING, message=_('This event does not allow uploading photos.'))
|
||||||
|
return redirect(event.get_absolute_url())
|
||||||
|
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
form = UploadEventPhotoForm()
|
form = UploadEventPhotoForm()
|
||||||
|
|
||||||
|
|
|
@ -240,6 +240,11 @@ def delete_talk(request, talk_id):
|
||||||
def propose_event_talk(request, event_id):
|
def propose_event_talk(request, event_id):
|
||||||
event = get_object_or_404(Event, id=event_id)
|
event = get_object_or_404(Event, id=event_id)
|
||||||
|
|
||||||
|
if not event.enable_presentations:
|
||||||
|
messages.add_message(request, messages.WARNING, message=_('This event does not allow presentations.'))
|
||||||
|
return redirect(event.get_absolute_url())
|
||||||
|
|
||||||
|
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
profile = request.user.profile
|
profile = request.user.profile
|
||||||
talks = list(Talk.objects.filter(speaker__user=profile))
|
talks = list(Talk.objects.filter(speaker__user=profile))
|
||||||
|
|
Loading…
Reference in a new issue