Пример #1
0
    slug = models.SlugField(primary_key=True)
    name = models.CharField(max_length=128)

    query_endpoint = models.URLField()
    update_endpoint = models.URLField(null=True, blank=True)
    graph_store_endpoint = models.URLField(null=True, blank=True)

    can_administer = permission_check('store', 'administer')
    can_query = permission_check('store', 'query')
    can_update = permission_check('store', 'update')

    def __unicode__(self):
        return self.name

register(['sparql.administer_store',
          'sparql.query_store',
          'sparql.update_store'],
         Store, 'sparql')

class UserPrivileges(models.Model):
    user = models.ForeignKey(User, null=True, blank=True)
    group = models.ForeignKey(Group, null=True, blank=True)

    allow_concurrent_queries = models.BooleanField()
    disable_throttle = models.BooleanField()
    throttle_threshold = models.FloatField(null=True, blank=True)
    deny_threshold = models.FloatField(null=True, blank=True)
    intensity_decay = models.FloatField(null=True, blank=True)

    disable_timeout = models.BooleanField()
    maximum_timeout = models.IntegerField(null=True)
Пример #2
0
            InstName,
            assname,
            )

    def save(self, *args, **kwargs):
        # custom save method
        #pdb.set_trace()
        from django.db import connection
        connection.features.can_return_id_from_insert = False
        #print "save"

        #print "name is",self.name, "=================== active is", self.active
        self.full_clean()
        super(Institution, self).save(*args, **kwargs)

register(['Acess'], Institution)  # Register model for Object permissions
register_model(Institution)  # Register model for to store information in fullhistory

from django.db.models.signals import post_save, pre_save
from schools.receivers import KLP_NewInst_Permission

# Call KLP_NewInst_Permission method on Institution save

post_save.connect(KLP_NewInst_Permission, sender=Institution)


class TaggedItem(models.Model):

    tag = models.SlugField()
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
Пример #3
0
from django.contrib.auth.models import Group

from object_permissions import register

# register internal perms
GROUP_PARAMS = {
    'perms':{
        'admin':{
            'label':'Admin',
            'description':'Can add or remove users, and edit their permissions for the group'
        }
    }
}

register(GROUP_PARAMS, Group)
Пример #4
0
    message = models.TextField(_('Message'))

    def __unicode__(self):
        return ",".join([self.subject, self.message[:20]])


class Inbox(models.Model):
    message   = models.ForeignKey(PrivateMessage, related_name='outgoing_pms', verbose_name=_('Message'))
    recipient = models.ForeignKey(User, related_name='incoming_pms', verbose_name=_('Recipient'))
    is_read   = models.BooleanField(_('Is read'), default=False)

    def __unicode__(self):
        return ",".join([self.message.subject, self.message.sender.username,
                         self.recipient.username])



signals.post_save.connect(
    Post.post_save, sender=Post, dispatch_uid='djforum_post_save')

signals.post_save.connect(
    Topic.post_save, sender=Topic, dispatch_uid='djforum_topic_save')

signals.post_save.connect(
    Forum.post_save, sender=Forum, dispatch_uid='djforum_forum_save')

registration.signals.user_registered.connect(Profile.user_registered)

from object_permissions import register
register(['view', 'edit', 'destroy'], Forum)
register(['view', 'edit', 'destroy'], Topic)
from django.contrib.auth.models import Group

from object_permissions import register

# register internal perms
GROUP_PARAMS = {
    'perms': {
        'admin': {
            'label':
            'Admin',
            'description':
            'Can add or remove users, and edit their permissions for the group'
        }
    }
}

register(GROUP_PARAMS, Group, 'object_permissions')
Пример #6
0
        if self.creator_name != operator_user.get_username():
            raise Exception("no permission to change permission of %s by %s" %
                            (self.name, operator_user.get_username()))

        future_permission = NodePermission(permission)
        if self.permission_group != "":
            current_permission_group_name = self.permission_group
            current_permission_group = Group.objects.filter(name=current_permission_group_name)
            current_permission_group.revoke_all(self)
        everyone_group = Group.objects.filter(name="everyone")
        everyone_group.revoke_all(self)
        operator_user.revoke(self)

        if future_permission.owner_read:
            operator_user.grant(PermissionConstants.READ, self)
        if future_permission.owner_write:
            operator_user.grant(PermissionConstants.WRITE, self)
        if future_permission.group_read:
            perm_group.grant(PermissionConstants.READ, self)
        if future_permission.group_write:
            perm_group.grant(PermissionConstants.WRITE, self)
        if future_permission.all_read:
            everyone_group.grant(PermissionConstants.READ, self)
        if future_permission.all_write:
            everyone_group.grant(PermissionConstants.WRITE, self)

        return True


register([PermissionConstants.READ, PermissionConstants.WRITE], TreeNode)
Пример #7
0
            periodic_task.delete()
        else:
            super(UpdateDefinition, self).save(*args, **kwargs)
        
    
    def delete(self, *args, **kwargs):
        super(UpdateDefinition, self).delete(*args, **kwargs)
        if self.periodic_task:
            self.periodic_task.crontab.delete()
            self.periodic_task.delete()
        

register(['update.administer_updatedefinition',
          'update.view_updatedefinition',
          'update.change_updatedefinition',
          'update.execute_updatedefinition',
          'update.delete_updatedefinition',
          'update.notifications_updatedefinition'],
         UpdateDefinition, 'update')

class WithLevels(object):
    levels = {'errors': {'label': 'errors',
                         'icon': 'gnome-icons/32x32/dialog-error.png'},
              'warnings': {'label': 'warnings',
                           'icon': 'gnome-icons/32x32/dialog-warning.png'},
              'success': {'label': 'success',
                          'icon': 'gnome-icons/32x32/emblem-default.png'},
              'inprogress': {'label': 'in progress',
                             'icon': 'gnome-icons/32x32/system-run.png'}}

    @property
Пример #8
0
from django.contrib.auth.models import Group

from object_permissions import register

# register internal perms
GROUP_PARAMS = {
    'perms': {
        'admin': {
            'label':
            'Admin',
            'description':
            'Can add or remove users, and edit their permissions for the group'
        }
    }
}

register(GROUP_PARAMS, Group)
Пример #9
0
                          created_by=created_by,
                          created_time=timezone.now(),
                          modify_by=created_by,
                          modify_time=timezone.now(),
                          status=0)
        project.save()
        return project

    def __unicode__(self):
        return '%s' % self.name


# register permissions onto Project
PROJECT_PERM_OWNER = 'owner'
PROJECT_PERM_USER = '******'
register([PROJECT_PERM_OWNER, PROJECT_PERM_USER], Project)
admin.site.register(Project)


class ProjectVersions(models.Model):
    project_id = models.IntegerField(db_index=True)
    project_version = models.IntegerField(db_index=True)
    diagram = models.CharField(max_length=20000, default="")
    upload_user = models.CharField(max_length=64)
    upload_time = models.DateTimeField(auto_now_add=True)
    file_type = models.CharField(max_length=16)
    file_name = models.CharField(max_length=256)
    hdfs_path = models.CharField(max_length=1024, default="")
    md5 = models.CharField(max_length=16)
    num_chunks = models.IntegerField()
Пример #10
0
                                                   active=2)
        if groupObjects:
            retStr = "<div class='hitarea hasChildren-hitarea collapsable-hitarea'></div>" + retStr + "<ul>"
            for groupObj in groupObjects:
                groupName = groupObj.name

                if groupName == '0':
                    groupName = 'Anganwadi Class'
                retStr = retStr + """<li id="%s"><span><a class="KLP_treetxt" onclick="return KLP_View(this)" href="/studentgroup/%s/view/" title="%s"> <img title="Class" src="/static_media/tree-images/reicons/studentgroup_%s.gif"> <span id="studentgroup_%s_text">%s</span>  </a></span></li>""" % (
                    groupObj.id, groupObj.id, groupName, groupObj.group_type,
                    groupObj.id, groupName)
            retStr = retStr + "</ul>"
        return retStr


register(['Acess'], Institution)  # Register model for Object permissions
register_model(
    Institution)  # Register model for to store information in fullhistory

from django.db.models.signals import post_save, pre_save
from schools.receivers import KLP_NewInst_Permission
# Call KLP_NewInst_Permission method on Institution save
post_save.connect(KLP_NewInst_Permission, sender=Institution)


class Child(models.Model):
    ''' This class stores the personnel information of the childrens'''
    firstName = models.CharField(max_length=50)
    middleName = models.CharField(max_length=50, blank=True, null=True)
    lastName = models.CharField(max_length=50, blank=True, null=True)
    uid = models.CharField(max_length=100, blank=True, null=True)
Пример #11
0
from django.contrib.auth.models import Group

from object_permissions import register

# register internal perms
GROUP_PARAMS = {
    'perms':{
        'admin':{
            'label':'Admin',
            'description':'Can add or remove users, and edit their permissions for the group'
        }
    }
}

register(GROUP_PARAMS, Group, 'object_permissions')
Пример #12
0
                                related_name='outgoing_pms',
                                verbose_name=_('Message'))
    recipient = models.ForeignKey(User,
                                  related_name='incoming_pms',
                                  verbose_name=_('Recipient'))
    is_read = models.BooleanField(_('Is read'), default=False)

    def __unicode__(self):
        return ",".join([
            self.message.subject, self.message.sender.username,
            self.recipient.username
        ])


signals.post_save.connect(Post.post_save,
                          sender=Post,
                          dispatch_uid='djforum_post_save')

signals.post_save.connect(Topic.post_save,
                          sender=Topic,
                          dispatch_uid='djforum_topic_save')

signals.post_save.connect(Forum.post_save,
                          sender=Forum,
                          dispatch_uid='djforum_forum_save')

registration.signals.user_registered.connect(Profile.user_registered)

from object_permissions import register
register(['view', 'edit', 'destroy'], Forum)
register(['view', 'edit', 'destroy'], Topic)
Пример #13
0
    def delete(self, *args, **kwargs):
        if self.dependents.all().count():
            raise IntegrityError("This series has dependent virtual series.")
        if not self.is_virtual:
            database_client = get_client()
            database_client.delete(self.slug)
        super(TimeSeries, self).delete(*args, **kwargs)

    def append(self, readings):
        database_client = get_client()
        result = database_client.append(self.slug, readings)
        self.last = result['last']
        self.save()
        return result

    def fetch(self, aggregation_type, interval, period_start=None, period_end=None):
        database_client = get_client()
        return database_client.fetch(self.slug, aggregation_type, interval, period_start, period_end)

    def get_admin_url(self):
        return reverse('timeseries-admin:detail', args=[self.slug])

    def __unicode__(self):
        return "%s (%s)" % (self.title, self.slug)

object_permissions.register(['openorg_timeseries.view_timeseries',
                             'openorg_timeseries.append_timeseries',
                             'openorg_timeseries.change_timeseries',
                             'openorg_timeseries.delete_timeseries'],
                            TimeSeries, 'openorg_timeseries')
Пример #14
0
    slug = models.SlugField(max_length=50, unique=True)
    created_date = models.DateTimeField(auto_now_add=True)

    def __unicode__(self):
        return self.name

    def save(self, *args, **kwargs):
        if not self.slug:
            self.slug = slugify(self.name)
        super(Client, self).save(*args, **kwargs)
        
    @models.permalink
    def get_absolute_url(self):
        return ('main-client', [self.slug])

register(['view','comment','approve'], Client)

class Project(models.Model):
    client = models.ForeignKey('main.Client', related_name="projects")
    name = models.CharField(max_length=255)
    slug = models.SlugField(max_length=50, unique=True)
    description = models.TextField(blank=True)
    created_date = models.DateTimeField(auto_now_add=True)

    def __unicode__(self):
        return u"%s (%s)" % (self.name, self.client.name)

    def save(self, *args, **kwargs):
        if not self.slug:
            self.slug = slugify(self.name)
        super(Project, self).save(*args, **kwargs)
Пример #15
0
            user.revoke(PRINCIPAL_PERM_DEFAULT, principal)
        if not user.has_perm(PRINCIPAL_PERM_USER, self):
            logger.info("user %s does not have user perm on principal %s", user, self)
            return False

        user.grant(PRINCIPAL_PERM_DEFAULT, self)

    def __unicode__(self):
        return self.name

    class Meta:
        db_table = 'kerberos_principal'

PRINCIPAL_PERM_DEFAULT = 'default'
PRINCIPAL_PERM_USER = '******'
register([PRINCIPAL_PERM_DEFAULT, PRINCIPAL_PERM_USER], Principal)
admin.site.register(Principal)


class PrincipalRequest(models.Model):
    user = models.ForeignKey(User)
    principal = models.ForeignKey(Principal)

    @staticmethod
    def apply(user, principal):
        try:
            principal_request = PrincipalRequest(user=user,
                                                 principal=principal)
            principal_request.save()
            return True
        except Exception, ex: