Beispiel #1
0
 def get_contributor_group(self):
     try:
         return Group.objects.get(name="%s_contributor" % self.app_label())
     except Group.DoesNotExist:
         create_permissions(self.get_module(),
                            app_label=self.ontology_as_mod)
         return Group.objects.get(name="%s_contributor" % self.app_label())
Beispiel #2
0
def update_permissions(*args, **kwargs):
    """ create the permissions related to the label module """
    assert kwargs.get('instance')
    # @TODO check that the slug changed or not to avoid permissions hijacking
    if kwargs.get('created', False):
        create_permissions(kwargs.get('instance').get_module(), app_label=kwargs.get('instance').ontology_as_mod)
    else:
        topic = kwargs.get('instance')
        group_name = '%s_contributor' % topic.ontology_as_mod
        # Update permission only if a author is given
        if topic.author is not None:
            try:
                topic.author.groups.get(name=group_name)
            except Group.DoesNotExist:
                try:
                    topic.author.groups.add(Group.objects.get(name=group_name))
                    topic.author.save()
                except Group.DoesNotExist:
                    pass
Beispiel #3
0
def update_permissions(*args, **kwargs):
    """ create the permissions related to the label module """
    assert kwargs.get('instance')
    # @TODO check that the slug changed or not to avoid permissions hijacking
    if kwargs.get('created', False):
        create_permissions(kwargs.get('instance').get_module(),
                           app_label=kwargs.get('instance').ontology_as_mod)
    else:
        topic = kwargs.get('instance')
        group_name = '%s_contributor' % topic.ontology_as_mod
        # Update permission only if a author is given
        if topic.author is not None:
            try:
                topic.author.groups.get(name=group_name)
            except Group.DoesNotExist:
                try:
                    topic.author.groups.add(Group.objects.get(name=group_name))
                    topic.author.save()
                except Group.DoesNotExist:
                    pass
Beispiel #4
0
 def get_contributor_group(self):
     try:
         return Group.objects.get(name="%s_contributor" % self.app_label())
     except Group.DoesNotExist:
         create_permissions(self.get_module(), app_label=self.ontology_as_mod)
         return Group.objects.get(name="%s_contributor" % self.app_label())
Beispiel #5
0
def update_permissions(*args, **kwargs):
    """ create the permissions related to the label module """
    assert kwargs.get('instance')
    # @TODO check that the slug changed or not to avoid permissions hijacking
    if kwargs.get('created', False):
        create_permissions(kwargs.get('instance').get_module(), app_label=kwargs.get('instance').module)