-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
TheBirdie
authored and
TheBirdie
committed
Feb 15, 2016
1 parent
60e90db
commit 323213c
Showing
1 changed file
with
49 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,49 @@ | ||
from django.db import models | ||
|
||
from sigma_core.models.user import User | ||
from sigma_core.models.group import Group | ||
|
||
class Publication(models.Model): | ||
""" | ||
Modelize a Publication. A Publication can be posted to a Group with the GroupPost model. | ||
""" | ||
|
||
# Warning! Both can be NULL ! | ||
poster_user = models.ForeignKey(User, null=True, related_name='created_publications', on_delete=models.SET_NULL) | ||
poster_group = models.ForeignKey(Group, null=True, related_name='created_publications', on_delete=models.SET_NULL) | ||
|
||
# Link to event ? | ||
created = models.DateTimeField(auto_now_add=True) | ||
title = models.CharField(max_length=255) | ||
body = models.TextField() | ||
|
||
posted_in = models.ManyToManyField(Group, through='GroupPost', related_name="publications") | ||
|
||
# Related fields | ||
# - comments (model PublicationComment) | ||
# - posts (model GroupPost) | ||
# - posted_in (model Group.publications through GroupPost) | ||
|
||
class GroupPost(models.Model): | ||
""" | ||
Modelize a Post on a Group. A Post is a link between a Publication and a Group. | ||
""" | ||
|
||
# Poster ? | ||
group = models.ForeignKey(Group, related_name='posts', on_delete=models.CASCADE) | ||
publication = models.ForeignKey(Publication, related_name='posts', on_delete=models.CASCADE) | ||
created = models.DateTimeField(auto_now_add=True) | ||
|
||
|
||
class PublicationComment(models.Model): | ||
""" | ||
Modelize a comment on a Publication | ||
""" | ||
|
||
user = models.ForeignKey(User, related_name='comments', on_delete=models.CASCADE) | ||
publication = models.ForeignKey('Publication', related_name='comments', on_delete=models.CASCADE) | ||
|
||
created = models.DateTimeField(auto_now_add=True) | ||
updated = models.DateTimeField(auto_now=True) | ||
comment = models.TextField() | ||
from django.db import models | ||
|
||
from sigma_core.models.user import User | ||
from sigma_core.models.group import Group | ||
|
||
class Publication(models.Model): | ||
""" | ||
Modelize a Publication. A Publication can be posted to a Group with the GroupPost model. | ||
""" | ||
|
||
# Warning! Both can be NULL ! | ||
poster_user = models.ForeignKey(User, null=True, related_name='created_publications', on_delete=models.SET_NULL) | ||
poster_group = models.ForeignKey(Group, null=True, related_name='created_publications', on_delete=models.SET_NULL) | ||
|
||
# Link to event ? | ||
created = models.DateTimeField(auto_now_add=True) | ||
title = models.CharField(max_length=255) | ||
body = models.TextField() | ||
|
||
posted_in = models.ManyToManyField(Group, through='GroupPost', related_name="publications") | ||
|
||
# Related fields | ||
# - comments (model PublicationComment) | ||
# - posts (model GroupPost) | ||
# - posted_in (model Group.publications through GroupPost) | ||
|
||
|
||
class GroupPost(models.Model): | ||
""" | ||
Modelize a Post on a Group. A Post is a link between a Publication and a Group. | ||
""" | ||
|
||
# Poster ? | ||
group = models.ForeignKey(Group, related_name='posts', on_delete=models.CASCADE) | ||
publication = models.ForeignKey(Publication, related_name='posts', on_delete=models.CASCADE) | ||
created = models.DateTimeField(auto_now_add=True) | ||
|
||
|
||
class PublicationComment(models.Model): | ||
""" | ||
Modelize a comment on a Publication | ||
""" | ||
|
||
user = models.ForeignKey(User, related_name='comments', on_delete=models.CASCADE) | ||
publication = models.ForeignKey('Publication', related_name='comments', on_delete=models.CASCADE) | ||
|
||
created = models.DateTimeField(auto_now_add=True) | ||
updated = models.DateTimeField(auto_now=True) | ||
comment = models.TextField() |