Пример #1
0
 def setUp(self):
     self.fp = FlatPage.objects.create(url='dummy/', title="dummy", enable_comments=False, registration_required=False)
     try:
         objectpermissions.register(FlatPage, self.perms)
     except objectpermissions.AlreadyRegistered:
         pass
     self.fp.save()
     
     self.u = User.objects.create_user('simple_guy','*****@*****.**', 'password')
     self.g = Group(name="simple_group")
     self.g.save()
Пример #2
0
    def setUp(self):
        self.fp = FlatPage.objects.create(url='dummy/',
                                          title="dummy",
                                          enable_comments=False,
                                          registration_required=False)
        try:
            objectpermissions.register(FlatPage, self.perms)
        except objectpermissions.AlreadyRegistered:
            pass
        self.fp.save()

        self.u = User.objects.create_user('simple_guy', '*****@*****.**',
                                          'password')
        self.g = Group(name="simple_group")
        self.g.save()
Пример #3
0
        """
        # Delete the source repository here
        self._vcs.delete()
        super(SourceRepository, self).delete()
    
    
    def list(self, path="/"):
        """
        Return a directory listing from the given repository path. **Not Implemented Yet**
        """
        pass


if settings.USE_OBJECT_PERMS:
    import objectpermissions
    objectpermissions.register(SourceRepository, ['read', 'write', 'owner'])


class RemoteSourceRepository(models.Model):
    """
    A source code repository on a remote server to which updates should be pushed.
    
    Pushing to a mirror on GitHub or LaunchPad is a common use.
    """
    repo = models.ForeignKey('SourceRepository', verbose_name=_('Repository'))
    name = models.SlugField(_('Name'))
    branch = models.CharField(_('Branch'), max_length=255, default='master')
    url = models.CharField(_('URL'), max_length=255, blank=True, help_text='Leave blank and the remote repository will be created')
    notes = models.TextField(_('Notes'), blank=True, 
        help_text=_('Notes about this remote repository'))
    active = models.BooleanField(_('Active'), default=True)
Пример #4
0
    """A Testing app"""
    firstname = models.CharField(blank=True, max_length=255)
    lastname = models.CharField(blank=True, max_length=255)
    favorite_color = models.CharField(blank=True, max_length=255)
    
    def __unicode__(self):
        return self.firstname

class SimpleTaggedItem(models.Model):
    tag = models.SlugField()
    simple_text = models.ForeignKey(SimpleText)

    def __unicode__(self):
        return self.tag

import objectpermissions
permissions = ['perm1', 'perm2', 'perm3', 'perm4']
objectpermissions.register(SimpleText, permissions)
objectpermissions.register(SimpleTaggedItem, permissions)

from django.contrib import admin
from objectpermissions.admin import TabularUserPermInline, StackedUserPermInline

class SimpleTaggedItemInline(admin.TabularInline):
    model = SimpleTaggedItem

class SimpleTextAdmin(admin.ModelAdmin):
    list_display = ('firstname','lastname','favorite_color')
    inlines = [SimpleTaggedItemInline, TabularUserPermInline, ]

admin.site.register(SimpleText, SimpleTextAdmin)
Пример #5
0
	name		= models.CharField(max_length=32, null=False, blank=False, db_index=True, verbose_name=u'Наименование')
	user		= models.ForeignKey(User, null=True, blank=True, db_index=True, verbose_name=u'Автор')
	app		= models.ForeignKey(ContentType, null=True, blank=True, db_index=True, verbose_name=u'Приложение')
	description	= models.TextField(null=True, blank=True, verbose_name=u'Подробности')

	def	__unicode__(self):
		return self.name

	class	Meta:
		app_label = 'gw'
		verbose_name = u'Категория'
		verbose_name_plural = u'Категории'
		ordering	= ('name', 'app', 'user')
		unique_together = (('name', 'user', 'app'),)

objectpermissions.register(Category, permissions)

class	Task(Object):
	'''
	Common parent for all tasks
	created - by History model
	Status:
		ToDo (was):	done:bool (New/Done)
		Assign (was):	done:bool x read:bool = New/Accepted/Done/Approved
		iCal vToDo:	Needs-Action/In-Progress/Completed/Cancelled
		iCal vEvent:	Tentative/Confirmed/Cancelled
		iCal vJournal:	Draft/Final/Canceled
	Restriction:
		Private:	None of the calendar data is visible.
		Public:		All of the calendar data is visible.
		Confidential:	Only start and end time of each instance is visible.
Пример #6
0
    description = models.TextField(null=True,
                                   blank=True,
                                   verbose_name=u'Подробности')

    def __unicode__(self):
        return self.name

    class Meta:
        app_label = 'gw'
        verbose_name = u'Категория'
        verbose_name_plural = u'Категории'
        ordering = ('name', 'app', 'user')
        unique_together = (('name', 'user', 'app'), )


objectpermissions.register(Category, permissions)


class Task(Object):
    '''
	Common parent for all tasks
	created - by History model
	Status:
		ToDo (was):	done:bool (New/Done)
		Assign (was):	done:bool x read:bool = New/Accepted/Done/Approved
		iCal vToDo:	Needs-Action/In-Progress/Completed/Cancelled
		iCal vEvent:	Tentative/Confirmed/Cancelled
		iCal vJournal:	Draft/Final/Canceled
	Restriction:
		Private:	None of the calendar data is visible.
		Public:		All of the calendar data is visible.
Пример #7
0
# Create your models here.

# Post
class Post(models.Model):
        user = models.ForeignKey(User)
        subject = models.CharField('Subject', max_length=128)
        post = models.TextField('')
        posted_at = models.DateTimeField("Posted at", auto_now=False)
        views = models.IntegerField()

        def shorten_post(self):
                if len(self.post) > 200:
                        last = 200
                        while not self.post[last] == ' ' and last > 190:
                                last -= 1
                        self.post = self.post[0:last] + ' ...'

# Comment
class Comment(models.Model):
        user = models.ForeignKey(User)
        on_post = models.ForeignKey(Post)
        subject = models.CharField(max_length=128)
        comment = models.TextField()
        posted_at = models.DateTimeField("Posted at", auto_now=True)

permissions = ['read', 'write', 'edit', 'delete']
objectpermissions.register(Post, permissions)
objectpermissions.register(Comment, permissions)

Пример #8
0

# Post
class Post(models.Model):
    user = models.ForeignKey(User)
    subject = models.CharField('Subject', max_length=128)
    post = models.TextField('')
    posted_at = models.DateTimeField("Posted at", auto_now=False)
    views = models.IntegerField()

    def shorten_post(self):
        if len(self.post) > 200:
            last = 200
            while not self.post[last] == ' ' and last > 190:
                last -= 1
            self.post = self.post[0:last] + ' ...'


# Comment
class Comment(models.Model):
    user = models.ForeignKey(User)
    on_post = models.ForeignKey(Post)
    subject = models.CharField(max_length=128)
    comment = models.TextField()
    posted_at = models.DateTimeField("Posted at", auto_now=True)


permissions = ['read', 'write', 'edit', 'delete']
objectpermissions.register(Post, permissions)
objectpermissions.register(Comment, permissions)
Пример #9
0
        Deletes the source repository before it deletes the record.
        """
        # Delete the source repository here
        self._vcs.delete()
        super(SourceRepository, self).delete()

    def list(self, path="/"):
        """
        Return a directory listing from the given repository path. **Not Implemented Yet**
        """
        pass


if settings.USE_OBJECT_PERMS:
    import objectpermissions
    objectpermissions.register(SourceRepository, ['read', 'write', 'owner'])


class RemoteSourceRepository(models.Model):
    """
    A source code repository on a remote server to which updates should be pushed.
    
    Pushing to a mirror on GitHub or LaunchPad is a common use.
    """
    repo = models.ForeignKey('SourceRepository', verbose_name=_('Repository'))
    name = models.SlugField(_('Name'))
    branch = models.CharField(_('Branch'), max_length=255, default='master')
    url = models.CharField(
        _('URL'),
        max_length=255,
        blank=True,
Пример #10
0
    def __unicode__(self):
        return self.firstname


class SimpleTaggedItem(models.Model):
    tag = models.SlugField()
    simple_text = models.ForeignKey(SimpleText)

    def __unicode__(self):
        return self.tag


import objectpermissions
permissions = ['perm1', 'perm2', 'perm3', 'perm4']
objectpermissions.register(SimpleText, permissions)
objectpermissions.register(SimpleTaggedItem, permissions)

from django.contrib import admin
from objectpermissions.admin import TabularUserPermInline, StackedUserPermInline


class SimpleTaggedItemInline(admin.TabularInline):
    model = SimpleTaggedItem


class SimpleTextAdmin(admin.ModelAdmin):
    list_display = ('firstname', 'lastname', 'favorite_color')
    inlines = [
        SimpleTaggedItemInline,
        TabularUserPermInline,