diff --git a/blechreiz/database.sqlite b/blechreiz/database.sqlite index 1b9bebf..b45dbe7 100644 Binary files a/blechreiz/database.sqlite and b/blechreiz/database.sqlite differ diff --git a/media/user_images/martin_circle.png b/blechreiz/media/user_images/martin_circle.png similarity index 100% rename from media/user_images/martin_circle.png rename to blechreiz/media/user_images/martin_circle.png diff --git a/media/user_images/rebecca_circle.png b/blechreiz/media/user_images/rebecca_circle.png similarity index 100% rename from media/user_images/rebecca_circle.png rename to blechreiz/media/user_images/rebecca_circle.png diff --git a/blechreiz/settings.py b/blechreiz/settings.py index 16471a2..0d76ce2 100644 --- a/blechreiz/settings.py +++ b/blechreiz/settings.py @@ -53,7 +53,7 @@ USE_TZ = True # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/var/www/example.com/media/" -MEDIA_ROOT = PROJECT_PATH + "/../media/" +MEDIA_ROOT = PROJECT_PATH + "/media/" # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. diff --git a/eventplanner/admin.py b/eventplanner/admin.py index edab05c..688213a 100644 --- a/eventplanner/admin.py +++ b/eventplanner/admin.py @@ -5,13 +5,13 @@ from eventplanner.models import Event, EventParticipation class EventParticipationInline(admin.TabularInline): model = EventParticipation extra = 1 - readonly_fields = ('musician',) - fields = ( 'musician', 'status', 'comment', ) + readonly_fields = ('user',) + fields = ( 'user', 'status', 'comment', ) has_add_permission = lambda self, req : False has_delete_permission = lambda self, req, obj : False template = "custom_tabular.html" - + class EventAdmin(admin.ModelAdmin): inlines = ( EventParticipationInline, ) diff --git a/eventplanner/models.py b/eventplanner/models.py index ed28693..d8db628 100644 --- a/eventplanner/models.py +++ b/eventplanner/models.py @@ -1,7 +1,8 @@ from django.db import models from django.utils.translation import ugettext as _ +from django.contrib.auth.models import User + -from musicians.models import Musician from datetime import datetime from location_field.models import PlainLocationField @@ -26,9 +27,7 @@ class Event ( models.Model ): 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") ) + participants = models.ManyToManyField( User, through='EventParticipation', verbose_name=_("participants") ) def __unicode__(self): return self.title + " ( " + self.get_type_display() + " ) " @@ -39,9 +38,9 @@ class Event ( models.Model ): super(Event, self).save(*args, **kwargs) # Create a "Don't Know" participation for each Musician - for m in Musician.objects.all(): - if not m in self.participants.all(): - EventParticipation.objects.create( event=self, musician = m, status='?', comment = '' ) + for u in User.objects.all(): + if not u in self.participants.all(): + EventParticipation.objects.create( event=self, user = u, status='?', comment = '' ) @property def displaytime(self): @@ -60,19 +59,18 @@ class EventParticipation( models.Model ): ) event = models.ForeignKey( Event, verbose_name=_("event") ) - musician = models.ForeignKey( Musician, verbose_name=_("musician") ) + user = models.ForeignKey( User, verbose_name=_("user") ) 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 + def get_username(self): + return self.user.username @staticmethod def hasUserSetParticipationForAllEvents( user ): futurePart = EventParticipation.objects.filter( event__date__gte = datetime.now() ) - maybeObjects = futurePart.filter( musician__user = user ).filter( status = '?' ) - + + maybeObjects = futurePart.filter( user = user ).filter( status = '?' ) if len( maybeObjects ) > 0: return False else: @@ -80,16 +78,16 @@ class EventParticipation( models.Model ): @staticmethod - def get_or_create( musician , event ): + def get_or_create( user , event ): try: - result = EventParticipation.objects.get( event = event, musician = musician ) + result = EventParticipation.objects.get( event = event, user = user ) except EventParticipation.DoesNotExist: - result = EventParticipation.objects.create( event = event, musician = musician, status='?', comment = '' ) + result = EventParticipation.objects.create( event = event, user = user, status='?', comment = '' ) return result class Meta: - unique_together = ("event", "musician") + unique_together = ("event", "user") permissions = ( ("change_others_participation", _("Can modify participation status of other users") ), ) diff --git a/eventplanner/serializers.py b/eventplanner/serializers.py index e0dc106..5daf0f0 100644 --- a/eventplanner/serializers.py +++ b/eventplanner/serializers.py @@ -5,20 +5,19 @@ from models import EventParticipation class ParticipationSerializer(serializers.ModelSerializer): - event = serializers.PrimaryKeyRelatedField( many=False, read_only = False ) - musician = serializers.Field( source='get_musician_username' ) -# musician = serializers.PrimaryKeyRelatedField( many=False, read_only = False ) + event = serializers.PrimaryKeyRelatedField( many=False, read_only = False ) + user = serializers.Field( source='get_username' ) def get_identity(self, data): """ This hook is required for bulk update. """ try: - return ( data.get('event', None), data.get('musician') ) + return ( data.get('event', None), data.get('user') ) except AttributeError: return None class Meta: model = EventParticipation - fields = ('event', 'musician', 'status', 'comment') + fields = ('event', 'user', 'status', 'comment') diff --git a/eventplanner/templates/eventplanner/eventplanning_view.html b/eventplanner/templates/eventplanner/eventplanning_view.html index 1b191f4..c2224a2 100644 --- a/eventplanner/templates/eventplanner/eventplanning_view.html +++ b/eventplanner/templates/eventplanner/eventplanning_view.html @@ -44,7 +44,7 @@ function putStatus( button, status ) { p = button.parent(); putObject = [ { "event": p.data("event-id"), - "musician": p.data("username"), + "user": p.data("username"), "status": status } ]; request = $.ajax( { @@ -66,7 +66,7 @@ putObject = [ { "event": $(this).data("event-id"), - "musician": $(this).data("username"), + "user": $(this).data("username"), "comment": $(this).val() } ]; $.ajax( { diff --git a/eventplanner/templates/eventplanner/events_grid.html b/eventplanner/templates/eventplanner/events_grid.html index 978feda..91d8822 100644 --- a/eventplanner/templates/eventplanner/events_grid.html +++ b/eventplanner/templates/eventplanner/events_grid.html @@ -72,7 +72,7 @@ dataObject = { "event" : $(this).data("event"), - "musician": $(this).data("musician"), + "user" : $(this).data("username"), "status" : $(this).children("button").data("status") }; @@ -117,7 +117,7 @@ Termin Datum - {% for name in musicianNames %} + {% for name in usernames %} {{ name|capfirst }} {% endfor %} @@ -133,7 +133,7 @@ {% for p in event.participation %} - + {% if p.status == "Yes" %}