Ejemplo n.º 1
0
class Poll(AutoSiteM2M, UpdateInfoBaseModel):
    """   
    inherited attributes from AutoSiteM2M:
        sites     -> ManyToManyField to Site
        on_site   -> sites.managers.CurrentSiteManager instance
        site_info -> a string with all site names, for admin.ModelAdmin list_display

    inherited attributes from UpdateInfoBaseModel:
        createtime     -> datetime of creation
        lastupdatetime -> datetime of the last change
        createby       -> ForeignKey to user who creaded this entry
        lastupdateby   -> ForeignKey to user who has edited this entry
    """
    question = models.CharField(max_length=200)
    active = models.BooleanField(
        default=True,
        help_text=_("Can users vote to this poll or just see the result?"),
    )

    permit_vote = limit_to_usergroups.UsergroupsModelField(
        help_text=_("Limit vote to user-types/user-groups."))
    permit_view = limit_to_usergroups.UsergroupsModelField(
        help_text=_("Limit result view to user-types/user-groups."))

    limit_ip = models.IntegerField(
        default=10,
        help_text=_("Limit votes from the same IP - 0 == unlimited"),
    )

    def __unicode__(self):
        return self.question

    class Meta:
        ordering = ('-createtime', '-lastupdatetime')
Ejemplo n.º 2
0
class LimitToUsergroupsTestModel(models.Model):
    permit_edit = limit_to_usergroups.UsergroupsModelField()
    permit_view = limit_to_usergroups.UsergroupsModelField()