Beispiel #1
0
class Join(MembershipMixin, views.Create):
    action = 'Beitreten *'
    data_field_classes = (
            fields.current_gestalt('created_by'),
            fields.related_object('group'),
            fields.current_gestalt('member'))
    description = (
            'Der Gruppe <em>{{ group }}</em> auf {{ site.name }} beitreten *')
    permission_required = 'memberships.join_group'
    template_name = 'memberships/join.html'

    def handle_no_permission(self):
        if self.request.user.is_authenticated and self.related_object.members.filter(
                pk=self.request.user.gestalt.pk).exists():
            django.contrib.messages.info(self.request, 'Du bist bereits Mitglied der Gruppe.')
            return django.http.HttpResponseRedirect(self.related_object.get_absolute_url())
        else:
            return super().handle_no_permission()
Beispiel #2
0
class Create(views.Create):
    permission_required = 'groups.create_group'

    action = 'Gruppe anlegen'
    menu = 'group'
    # parent = 'group-index'
    title = 'Neue Gruppe'

    model = models.Group

    data_field_classes = (fields.current_gestalt('gestalt_created', null=True),
                          fields.model_field('name'))
Beispiel #3
0
class MemberAdd(MembershipMixin, views.Create):
    action = 'Mitglied aufnehmen'
    data_field_classes = (fields.current_gestalt('created_by'),
                          fields.related_object('group'),
                          fields.email_gestalt('member'))
    permission_required = 'memberships.create_membership'

    def form_valid(self, form):
        try:
            return super().form_valid(form)
        except db.IntegrityError:
            messages.info(self.request, 'Die Gestalt ist bereits Mitglied.')
            return http.HttpResponseRedirect(self.get_success_url())

    def get_success_url(self):
        return urls.reverse('members', args=(self.related_object.pk, ))