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)
|
||||
class Meta:
|
||||
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 = {
|
||||
'place': Lookup(source=Place),
|
||||
'start_time': DateTimeWidget,
|
||||
|
@ -302,7 +302,13 @@ class NewEventDetailsForm(forms.ModelForm):
|
|||
|
||||
class Meta:
|
||||
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):
|
||||
|
|
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)
|
||||
|
||||
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
|
||||
def is_over(self):
|
||||
return self.end_time <= timezone.now()
|
||||
|
|
|
@ -210,6 +210,7 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if event.enable_presentations %}
|
||||
<div class="row mb-2">
|
||||
<div class="col-3" width="120px"><b>Presentations:</b></div>
|
||||
<div class="col-9">
|
||||
|
@ -224,9 +225,11 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
||||
{% if event.enable_comments %}
|
||||
<div class="container container-secondary mt-3">
|
||||
<div class="row">
|
||||
<div class="col"><h4>Comments</h4></div>
|
||||
|
@ -270,6 +273,7 @@
|
|||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
|
@ -335,6 +339,7 @@
|
|||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% if event.enable_photos %}
|
||||
<div class="container container-secondary mb-3">
|
||||
<div class="row">
|
||||
<div class="col"><h4>Photos</h4></div>
|
||||
|
@ -362,6 +367,7 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -476,6 +476,10 @@ def attended_event(request, event_id):
|
|||
|
||||
def comment_event(request, 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:
|
||||
messages.add_message(request, messages.WARNING, message=_("You must be logged in to comment."))
|
||||
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.'))
|
||||
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':
|
||||
form = UploadEventPhotoForm()
|
||||
|
||||
|
|
|
@ -240,6 +240,11 @@ def delete_talk(request, talk_id):
|
|||
def propose_event_talk(request, 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':
|
||||
profile = request.user.profile
|
||||
talks = list(Talk.objects.filter(speaker__user=profile))
|
||||
|
|
Loading…
Reference in a new issue