diff --git a/events/forms.py b/events/forms.py index 6697b35..fd3b418 100644 --- a/events/forms.py +++ b/events/forms.py @@ -74,6 +74,33 @@ class DateWidget(forms.DateInput): super(DateWidget, self).__init__(attrs=attrs) +class SimpleTimeWidget(forms.Select): + """A single dropdown time widget + """ + def __init__(self, attrs=None): + self.time_class = 'timepicker' + if not attrs: + attrs = {} + if 'time_class' in attrs: + self.time_class = attrs.pop('time_class') + if 'class' not in attrs: + attrs['class'] = 'time' + + choices = [] + for m in ('AM', 'PM'): + for hour in range(0, 12): + if hour == 0: + hour = 12 + for minute in range(00, 60, 30): + choices.append(('%02d:%02d %s' % (hour, minute, m), ('%02d:%02d %s' % (hour, minute, m)))) + + super(SimpleTimeWidget, self).__init__(attrs, choices) + + def value_from_datadict(self, data, files, name): + value = super(SimpleTimeWidget, self).value_from_datadict(data, files, name) + t = strptime(value, "%I:%M %p") + return strftime("%H:%M:%S", t) + class TimeWidget(forms.MultiWidget): """A more-friendly time widget. """ @@ -134,7 +161,7 @@ class DateTimeWidget(forms.SplitDateTimeWidget): super(DateTimeWidget, self).__init__(attrs, date_format, time_format) self.widgets = ( DateWidget(attrs=attrs), - TimeWidget(attrs=attrs), + SimpleTimeWidget(attrs=attrs), ) def decompress(self, value): diff --git a/events/migrations/0045_change_field_help_text.py b/events/migrations/0045_change_field_help_text.py new file mode 100644 index 0000000..bca926d --- /dev/null +++ b/events/migrations/0045_change_field_help_text.py @@ -0,0 +1,68 @@ +# Generated by Django 2.0 on 2018-09-07 14:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('events', '0044_add_event_settings'), + ] + + operations = [ + migrations.AlterField( + model_name='commonevent', + name='announce_url', + field=models.URLField(blank=True, null=True, verbose_name='Announcement URL'), + ), + migrations.AlterField( + model_name='commonevent', + name='end_time', + field=models.DateTimeField(db_index=True, verbose_name='End Time'), + ), + migrations.AlterField( + model_name='commonevent', + name='start_time', + field=models.DateTimeField(db_index=True, verbose_name='Start Time'), + ), + migrations.AlterField( + model_name='commonevent', + name='summary', + field=models.TextField(blank=True, help_text='Markdown formatting supported', null=True), + ), + migrations.AlterField( + model_name='commonevent', + name='web_url', + field=models.URLField(blank=True, null=True, verbose_name='Website URL'), + ), + migrations.AlterField( + model_name='event', + name='announce_url', + field=models.URLField(blank=True, null=True, verbose_name='Announcement URL'), + ), + migrations.AlterField( + model_name='event', + name='end_time', + field=models.DateTimeField(db_index=True, verbose_name='End Time'), + ), + migrations.AlterField( + model_name='event', + name='start_time', + field=models.DateTimeField(db_index=True, verbose_name='Start Time'), + ), + migrations.AlterField( + model_name='event', + name='summary', + field=models.TextField(blank=True, help_text='Markdown formatting supported', null=True), + ), + migrations.AlterField( + model_name='event', + name='web_url', + field=models.URLField(blank=True, null=True, verbose_name='Website URL'), + ), + migrations.AlterField( + model_name='eventcomment', + name='body', + field=models.TextField(help_text='Markdown formatting supported'), + ), + ] diff --git a/events/models/events.py b/events/models/events.py index 234ffa0..0d5d218 100644 --- a/events/models/events.py +++ b/events/models/events.py @@ -72,15 +72,15 @@ class Event(models.Model): series = models.ForeignKey('EventSeries',related_name='instances', null=True, blank=True, on_delete=models.SET_NULL) status = models.SmallIntegerField(choices=STATUSES, default=CONFIRMED, db_index=True) - start_time = models.DateTimeField(help_text=_('Date and time that the event starts'), verbose_name=_('Start Time'), db_index=True) - end_time = models.DateTimeField(help_text=_('Date and time that the event ends'), verbose_name=_('End Time'), db_index=True) + start_time = models.DateTimeField(verbose_name=_('Start Time'), db_index=True) + end_time = models.DateTimeField(verbose_name=_('End Time'), db_index=True) - summary = models.TextField(help_text=_('Summary of the Event'), blank=True, null=True) + summary = models.TextField(help_text=_('Markdown formatting supported'), blank=True, null=True) place = models.ForeignKey(Place, blank=True, null=True, on_delete=models.CASCADE) - web_url = models.URLField(verbose_name=_('Website'), help_text=_('URL for the event'), max_length=200, blank=True, null=True) - announce_url = models.URLField(verbose_name=_('Announcement'), help_text=_('URL for the announcement'), max_length=200, blank=True, null=True) + web_url = models.URLField(verbose_name=_('Website URL'), max_length=200, blank=True, null=True) + announce_url = models.URLField(verbose_name=_('Announcement URL'), max_length=200, blank=True, null=True) created_by = models.ForeignKey(UserProfile, on_delete=models.CASCADE) created_time = models.DateTimeField(help_text=_('the date and time when the event was created'), default=timezone.now, db_index=True) @@ -297,7 +297,7 @@ class EventComment(MPTTModel): ] author = models.ForeignKey(UserProfile, on_delete=models.CASCADE) event = models.ForeignKey(Event, related_name='comments', on_delete=models.CASCADE) - body = models.TextField() + body = models.TextField(help_text=_('Markdown formatting supported')) created_time = models.DateTimeField(default=timezone.now, db_index=True) status = models.SmallIntegerField(choices=STATUSES, default=APPROVED, db_index=True) parent = TreeForeignKey('self', null=True, blank=True, related_name='children', db_index=True, on_delete=models.SET_NULL) @@ -314,9 +314,9 @@ class CommonEvent(models.Model): organization = models.ForeignKey(Organization, null=True, blank=True, on_delete=models.CASCADE) parent = models.ForeignKey('CommonEvent', related_name='sub_events', null=True, blank=True, on_delete=models.SET_NULL) - start_time = models.DateTimeField(help_text=_('Date and time that the event starts'), verbose_name=_('Start Time'), db_index=True) - end_time = models.DateTimeField(help_text=_('Date and time that the event ends'), verbose_name=_('End Time'), db_index=True) - summary = models.TextField(help_text=_('Summary of the Event'), blank=True, null=True) + start_time = models.DateTimeField(verbose_name=_('Start Time'), db_index=True) + end_time = models.DateTimeField(verbose_name=_('End Time'), db_index=True) + summary = models.TextField(help_text=_('Markdown formatting supported'), blank=True, null=True) continent = models.ForeignKey(Continent, null=True, blank=True, on_delete=models.SET_NULL) country = models.ForeignKey(Country, null=True, blank=True, on_delete=models.SET_NULL) @@ -324,8 +324,8 @@ class CommonEvent(models.Model): city = models.ForeignKey(City, null=True, blank=True, on_delete=models.SET_NULL) place = models.ForeignKey(Place, blank=True, null=True, on_delete=models.SET_NULL) - web_url = models.URLField(verbose_name=_('Website'), help_text=_('URL for the event'), max_length=200, blank=True, null=True) - announce_url = models.URLField(verbose_name=_('Announcement'), help_text=_('URL for the announcement'), max_length=200, blank=True, null=True) + web_url = models.URLField(verbose_name=_('Website URL'), max_length=200, blank=True, null=True) + announce_url = models.URLField(verbose_name=_('Announcement URL'), max_length=200, blank=True, null=True) created_by = models.ForeignKey(UserProfile, on_delete=models.CASCADE) created_time = models.DateTimeField(help_text=_('the date and time when the event was created'), default=timezone.now, db_index=True) diff --git a/get_together/templates/get_together/events/edit_event.html b/get_together/templates/get_together/events/edit_event.html index 8f53cd5..96d4cdc 100644 --- a/get_together/templates/get_together/events/edit_event.html +++ b/get_together/templates/get_together/events/edit_event.html @@ -51,6 +51,9 @@ $(document).ready(function(){ $("#id_end_time_0").datepicker(); + $("#id_start_time_1").selectmenu({width: 150}); + $("#id_end_time_1").selectmenu({width: 150}); + }); diff --git a/get_together/templates/get_together/new_event/create_event.html b/get_together/templates/get_together/new_event/create_event.html index 3489906..27ccfe2 100644 --- a/get_together/templates/get_together/new_event/create_event.html +++ b/get_together/templates/get_together/new_event/create_event.html @@ -27,6 +27,8 @@ $(document).ready(function(){ $("#id_end_time_0").datepicker(); + $("#id_start_time_1").selectmenu({width: 150}); + $("#id_end_time_1").selectmenu({width: 150}); }); diff --git a/get_together/templates/get_together/orgs/create_common_event.html b/get_together/templates/get_together/orgs/create_common_event.html index 376beaa..b583db1 100644 --- a/get_together/templates/get_together/orgs/create_common_event.html +++ b/get_together/templates/get_together/orgs/create_common_event.html @@ -95,6 +95,9 @@ $(document).ready(function(){ $("#id_category").selectmenu(); $("#id_tz").selectmenu(); + + $("#id_start_time_1").selectmenu({width: 150}); + $("#id_end_time_1").selectmenu({width: 150}); });