diff --git a/blechreiz/database.sqlite b/blechreiz/database.sqlite index bb838bb..7763ca4 100644 Binary files a/blechreiz/database.sqlite and b/blechreiz/database.sqlite differ diff --git a/blechreiz/settings.py b/blechreiz/settings.py index 4c25b56..b8a1c7a 100644 --- a/blechreiz/settings.py +++ b/blechreiz/settings.py @@ -153,7 +153,7 @@ INSTALLED_APPS = ( REST_FRAMEWORK = { - 'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAdminUser',), + 'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated',), 'PAGINATE_BY': 10 } diff --git a/blechreiz/urls.py b/blechreiz/urls.py index 606ccb4..2187e75 100644 --- a/blechreiz/urls.py +++ b/blechreiz/urls.py @@ -16,15 +16,9 @@ from django.conf.urls.static import static admin.autodiscover() urlpatterns = patterns('', - # Examples: - # url(r'^$', 'blechreiz.views.home', name='home'), - # url(r'^blechreiz/', include('blechreiz.foo.urls')), - - # Uncomment the admin/doc line below to enable admin documentation: - url(r'^admin/doc/', include('django.contrib.admindocs.urls')), - - # Uncomment the next line to enable the admin: - url(r'^admin/', include(admin.site.urls)), + url(r'^events/', include( eventplanner.views.urls) ), + url(r'^admin/', include(admin.site.urls) ), + url(r'^admin/doc/', include('django.contrib.admindocs.urls') ), url(r'^musicians/$', MusicianList.as_view() ), url(r'^musicians/(?P[\w]+)$', user_edit ), @@ -32,10 +26,4 @@ urlpatterns = patterns('', url(r'^website/$', website.views.home_view), url(r'^login/$', website.views.login_view), url(r'^logout/$', website.views.logout_view), - url(r'^events/$', eventplanner.views.eventplanning_view), - url(r'^eventParticipation/$', eventplanner.views.event_participation_detail ), - url(r'^eventParticipation/(\w+)/$', eventplanner.views.event_participation_detail ), - url(r'^eventParticipation/(\w+)/(\d+)$', eventplanner.views.event_participation_detail ), - url(r'^events/grid$', eventplanner.views.events_grid ), - url(r'^events/(?P\d+)$', eventplanner.views.EventUpdate.as_view() ), ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ No newline at end of file diff --git a/eventplanner/admin.py b/eventplanner/admin.py index d5e4562..edab05c 100644 --- a/eventplanner/admin.py +++ b/eventplanner/admin.py @@ -10,7 +10,7 @@ class EventParticipationInline(admin.TabularInline): has_add_permission = lambda self, req : False has_delete_permission = lambda self, req, obj : False - template = "custom_tabular.html" + template = "custom_tabular.html" class EventAdmin(admin.ModelAdmin): diff --git a/eventplanner/locale/de/LC_MESSAGES/django.po b/eventplanner/locale/de/LC_MESSAGES/django.po index 3808a99..10e733f 100644 --- a/eventplanner/locale/de/LC_MESSAGES/django.po +++ b/eventplanner/locale/de/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-06-30 10:55+0200\n" +"POT-Creation-Date: 2013-06-30 16:20+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,18 +18,22 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: models.py:11 +#: models.py:10 msgid "Rehearsal" msgstr "Probe" -#: models.py:12 +#: models.py:11 msgid "Concert" msgstr "Konzert" -#: models.py:13 +#: models.py:12 msgid "General Rehearsal" msgstr "Generalprobe" +#: models.py:13 +msgid "Party" +msgstr "Feier" + #: models.py:16 msgid "title" msgstr "Titel" @@ -39,52 +43,70 @@ msgid "type" msgstr "Typ" #: models.py:18 -msgid "date" -msgstr "Datum" - -#: models.py:19 -msgid "time" -msgstr "Uhrzeit" - -#: models.py:20 -msgid "participants" -msgstr "Teilnehmer" - -#: models.py:22 -msgid "description" -msgstr "Beschreibung" - -#: models.py:23 msgid "location" msgstr "Ort" -#: models.py:44 +#: models.py:19 +msgid "description" +msgstr "Beschreibung" + +#: models.py:21 +msgid "date" +msgstr "Datum" + +#: models.py:22 +msgid "time" +msgstr "Uhrzeit" + +#: models.py:23 +msgid "meeting_time" +msgstr "" + +#: models.py:25 +msgid "participants" +msgstr "Teilnehmer" + +#: models.py:45 msgid "?" msgstr "" -#: models.py:45 +#: models.py:46 msgid "Yes" msgstr "Ja" -#: models.py:46 +#: models.py:47 msgid "No" msgstr "Nein" -#: models.py:49 +#: models.py:50 msgid "event" msgstr "Termin" -#: models.py:50 +#: models.py:51 msgid "musician" msgstr "Musiker" -#: models.py:51 +#: models.py:52 msgid "status" msgstr "Status" -#: models.py:52 +#: models.py:53 msgid "comment" msgstr "Kommentar" -#~ msgid "Delete?" -#~ msgstr "Löschen" +#: models.py:72 +msgid "Can modify participation status of other users" +msgstr "" + +#: templates/custom_tabular.html:17 +msgid "Delete?" +msgstr "Löschen" + +#: templates/custom_tabular.html:74 +#, python-format +msgid "Add another %(verbose_name)s" +msgstr "" + +#: templates/custom_tabular.html:75 +msgid "Remove" +msgstr "" diff --git a/eventplanner/models.py b/eventplanner/models.py index 12626bd..155c6b3 100644 --- a/eventplanner/models.py +++ b/eventplanner/models.py @@ -1,6 +1,5 @@ from django.db import models from django.utils.translation import ugettext as _ -from locpick.field import LocationField from musicians.models import Musician @@ -10,19 +9,21 @@ class Event ( models.Model ): EVENT_TYPES = ( ( 'Reh', _('Rehearsal') ), ( 'Conc', _('Concert') ), - ( 'GenReh', _('General Rehearsal') ), + ( 'GenReh', _('General Rehearsal') ), + ( 'Party', _('Party') ), ) title = models.CharField( max_length=40, verbose_name = _("title") ) - type = models.CharField( max_length=6, choices=EVENT_TYPES, default='Reh', verbose_name= _("type") ) + type = models.CharField( max_length=6, choices=EVENT_TYPES, default='Reh', verbose_name= _("type") ) + location = models.TextField( blank=False, verbose_name=_("location") ) + desc = models.TextField( blank=True, verbose_name=_("description")) + date = models.DateField( verbose_name= _("date") ) time = models.TimeField( null=True, blank=True, verbose_name = _("time") ) + meeting_time = models.TimeField( null=True, blank=True, verbose_name = _("meeting_time") ) + participants = models.ManyToManyField( Musician, through='EventParticipation', verbose_name=_("participants") ) - desc = models.TextField( blank=True, verbose_name=_("description")) - location = LocationField( verbose_name=_("location") ) - - def __unicode__(self): return self.title + " ( " + self.get_type_display() + " ) " @@ -51,10 +52,25 @@ class EventParticipation( models.Model ): status = models.CharField ( max_length=3, choices = OPTIONS, default='?', verbose_name=_("status") ) comment = models.CharField ( max_length=64, blank=True, verbose_name=_("comment") ) + def get_musician_username(self): return self.musician.user.username + + + @staticmethod + def get_or_create( musician , event ): + try: + result = EventParticipation.objects.get( event = event, musician = musician ) + except EventParticipation.DoesNotExist: + result = EventParticipation.objects.create( event = event, musician = musician, status='?', comment = '' ) + return result + class Meta: unique_together = ("event", "musician") + permissions = ( + ("change_others_participation", _("Can modify participation status of other users") ), + ) + \ No newline at end of file diff --git a/eventplanner/templates/custom_tabular.html b/eventplanner/templates/custom_tabular.html new file mode 100644 index 0000000..355cc9a --- /dev/null +++ b/eventplanner/templates/custom_tabular.html @@ -0,0 +1,78 @@ +{% load i18n admin_static admin_modify %} +
+ +
+ + diff --git a/eventplanner/templates/eventplanner/eventplanning_view.html b/eventplanner/templates/eventplanner/eventplanning_view.html index a82e4a9..6f5c9a8 100644 --- a/eventplanner/templates/eventplanner/eventplanning_view.html +++ b/eventplanner/templates/eventplanner/eventplanning_view.html @@ -51,7 +51,7 @@ request = $.ajax( { type: "PUT", - url: "/eventParticipation/" + p.data("username") + "/" + p.data("event-id"), + url: "{% url 'event_api' %}", contentType: "application/json", data: JSON.stringify(putObject) }); @@ -73,7 +73,7 @@ $.ajax( { type: "PUT", - url: "/eventParticipation/" + $(this).data("username") + "/" + $(this).data("event-id"), + url: "{% url 'event_api' %}", contentType: "application/json", data: JSON.stringify(putObject) }); diff --git a/eventplanner/templates/eventplanner/events_grid.html b/eventplanner/templates/eventplanner/events_grid.html index ffe486d..44d073c 100644 --- a/eventplanner/templates/eventplanner/events_grid.html +++ b/eventplanner/templates/eventplanner/events_grid.html @@ -29,9 +29,14 @@ {% addtoblock "js" %}