Created
September 2, 2011 19:51
-
-
Save issackelly/1189701 to your computer and use it in GitHub Desktop.
Project Model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProjectResource(ModelResource): | |
class Meta: | |
queryset = Project.objects.all() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProjectResource(ModelResource): | |
corkboards = fields.ToManyField("loupe.api.CorkboardResource", "corkboard_set", full=True) | |
def get_object_list(self, request, *args, **kwargs): | |
return Project.objects.filter(members=request.user) | |
class Meta: | |
queryset = Project.objects.all() | |
authentication = BasicAuthentication() | |
authorization = DjangoAuthorization() | |
allowed_methods = ["get", "post"] | |
ordering = ['created_on', 'updated_on'] | |
filtering = { | |
'members': ALL_WITH_RELATIONS, | |
'title': ALL, | |
'description': ALL, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Project(TitleSlugDescriptionModel): | |
""" | |
Stores the projects that corkboards belong to. | |
Only administrators should be able to set these up | |
""" | |
user = models.ForeignKey(User) | |
members = models.ManyToManyField(User, related_name="ProjectMember") | |
created_on = models.DateTimeField(_('Created On'), default=datetime.now, editable=False) | |
updated_on = models.DateTimeField(_('Updated On'), editable=False, null=True, blank=True) | |
class Meta: | |
ordering = ['-created_on',] | |
def __unicode__(self): | |
return '%s' % (self.title) | |
def save(self, *args, **kwargs): | |
self.updated_on = datetime.now() | |
super(Project, self).save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment