diff --git a/blechreiz/database.sqlite b/blechreiz/database.sqlite index 2b79c92..a79646f 100644 Binary files a/blechreiz/database.sqlite and b/blechreiz/database.sqlite differ diff --git a/blechreiz/media/user_images/MartinB_1.png b/blechreiz/media/user_images/MartinB_1.png deleted file mode 100644 index 63220e4..0000000 Binary files a/blechreiz/media/user_images/MartinB_1.png and /dev/null differ diff --git a/blechreiz/media/user_images/Rebecca_1.png b/blechreiz/media/user_images/Rebecca_1.png deleted file mode 100644 index fdfd5e1..0000000 Binary files a/blechreiz/media/user_images/Rebecca_1.png and /dev/null differ diff --git a/blechreiz/media/user_images/martin.png b/blechreiz/media/user_images/martin.png deleted file mode 100644 index 63220e4..0000000 Binary files a/blechreiz/media/user_images/martin.png and /dev/null differ diff --git a/blechreiz/media/user_images/martin_1.png b/blechreiz/media/user_images/martin_1.png deleted file mode 100644 index 63220e4..0000000 Binary files a/blechreiz/media/user_images/martin_1.png and /dev/null differ diff --git a/blechreiz/media/user_images/martin_circle.png b/blechreiz/media/user_images/martin_circle.png deleted file mode 100644 index a1183fc..0000000 Binary files a/blechreiz/media/user_images/martin_circle.png and /dev/null differ diff --git a/blechreiz/media/user_images/martin_thumb.png b/blechreiz/media/user_images/martin_thumb.png deleted file mode 100644 index a1183fc..0000000 Binary files a/blechreiz/media/user_images/martin_thumb.png and /dev/null differ diff --git a/blechreiz/media/user_images/rebecca.png b/blechreiz/media/user_images/rebecca.png deleted file mode 100644 index fdfd5e1..0000000 Binary files a/blechreiz/media/user_images/rebecca.png and /dev/null differ diff --git a/blechreiz/media/user_images/rebecca_1.png b/blechreiz/media/user_images/rebecca_1.png deleted file mode 100644 index 94e815a..0000000 Binary files a/blechreiz/media/user_images/rebecca_1.png and /dev/null differ diff --git a/blechreiz/media/user_images/rebecca_circle.png b/blechreiz/media/user_images/rebecca_circle.png deleted file mode 100644 index 5601bad..0000000 Binary files a/blechreiz/media/user_images/rebecca_circle.png and /dev/null differ diff --git a/blechreiz/media/user_images/rebecca_vildosola.png b/blechreiz/media/user_images/rebecca_vildosola.png deleted file mode 100644 index fdfd5e1..0000000 Binary files a/blechreiz/media/user_images/rebecca_vildosola.png and /dev/null differ diff --git a/blechreiz/media/user_images/rebecca_vildosola_thumb.png b/blechreiz/media/user_images/rebecca_vildosola_thumb.png deleted file mode 100644 index 5601bad..0000000 Binary files a/blechreiz/media/user_images/rebecca_vildosola_thumb.png and /dev/null differ diff --git a/eventplanner/models.py b/eventplanner/models.py index d57a4e0..5c8b783 100644 --- a/eventplanner/models.py +++ b/eventplanner/models.py @@ -1,8 +1,9 @@ from django.db import models from django.utils.translation import ugettext as _ -from django.contrib.auth.models import User +from django.contrib.auth.models import User, Permission +from django.db.models import Q from datetime import datetime from location_field.models import PlainLocationField @@ -78,6 +79,9 @@ class EventParticipation( models.Model ): @staticmethod def hasUserSetParticipationForAllEvents( user ): + if not EventParticipation.isMember(user): + return True + futurePart = EventParticipation.objects.filter( event__date__gte = datetime.now() ) maybeObjects = futurePart.filter( user = user ).filter( status = '?' ) @@ -86,6 +90,18 @@ class EventParticipation( models.Model ): else: return True + @staticmethod + def isMember( user ): + return user.has_perm('eventplanner.member') + + @staticmethod + def isAdmin( user ): + return user.has_perm('eventplanner.admin') + + @staticmethod + def members(): + perm = Permission.objects.get( codename='member' ) + return User.objects.filter(Q(groups__permissions=perm) | Q(user_permissions=perm) ).distinct() @staticmethod def get_or_create( user , event ): @@ -99,8 +115,9 @@ class EventParticipation( models.Model ): class Meta: unique_together = ("event", "user") permissions = ( - ("change_others_participation", _("Can modify participation status of other users") ), + ("admin", _("Admin") ), + ("member", _("Member") ), ) - + \ No newline at end of file diff --git a/eventplanner/serializers.py b/eventplanner/serializers.py index 5daf0f0..f7cd4b0 100644 --- a/eventplanner/serializers.py +++ b/eventplanner/serializers.py @@ -7,10 +7,12 @@ from models import EventParticipation class ParticipationSerializer(serializers.ModelSerializer): event = serializers.PrimaryKeyRelatedField( many=False, read_only = False ) user = serializers.Field( source='get_username' ) + status = serializers.CharField( source='status', required=False ) def get_identity(self, data): - """ This hook is required for bulk update. """ + """ This hook is required for bulk update. """ try: + print "get_identity event:" + str( data.get('event', None) ) + " user " + str( data.get('user') ) return ( data.get('event', None), data.get('user') ) except AttributeError: return None diff --git a/eventplanner/templates/eventplanner/eventplanning_view.html b/eventplanner/templates/eventplanner/eventplanning_view.html index 4a6a696..ee17e42 100644 --- a/eventplanner/templates/eventplanner/eventplanning_view.html +++ b/eventplanner/templates/eventplanner/eventplanning_view.html @@ -41,38 +41,36 @@ } } - function putStatus( button, status ) { + function putStatus( button, status ) + { $("#saving").html("Speichere.."); p = button.parent(); putObject = [ { "event": p.data("event-id"), "user": p.data("username"), "status": status } ]; - + request = $.ajax( { type: "PUT", url: "{% url 'event_api' %}", contentType: "application/json", data: JSON.stringify(putObject), - success: function() { $("#saving").html("Ok"); } + success: function() { $("#saving").html("Ok"); }, + error: function(jqXHR, text, errorText) { console.log("Ajax failed " + errorText + JSON.stringify(putObject) ); } }); setEventButtonStatus( button, status ); - //request.done(function(jqXHR, textStatus) { - // setEventButtonStatus( button, status ) - //}); } $(function(){ $(".event-comment").bindWithDelay("keypress", function() { - $("#saving").html("Speichere.."); putObject = [ { "event": $(this).data("event-id"), "user": $(this).data("username"), "comment": $(this).val() } ]; - + $.ajax( { type: "PUT", url: "{% url 'event_api' %}", @@ -103,13 +101,17 @@