Browse Source

Thread and post models

Rafał Pitoń 10 years ago
parent
commit
29cea3a594
2 changed files with 47 additions and 14 deletions
  1. 26 2
      misago/threads/models/post.py
  2. 21 12
      misago/threads/models/thread.py

+ 26 - 2
misago/threads/models/post.py

@@ -3,5 +3,29 @@ from django.db import models
 from misago.conf import settings
 
 
-class Post(object):#(models.Model):
-    pass
+class Post(models.Model):
+    forum = models.ForeignKey('misago_forums.Forum')
+    thread = models.ForeignKey('misago_threads.Thread')
+    poster = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True,
+                               on_delete=models.SET_NULL)
+    poster_name = models.CharField(max_length=255)
+    poster_ip = models.GenericIPAddressField()
+    post = models.TextField()
+    post_parsed = models.TextField()
+    post_checksum = models.CharField(max_length=64)
+    mentions = models.ManyToManyField(settings.AUTH_USER_MODEL,
+                                      related_name="mention_set")
+    has_attachments = models.BooleanField(default=False)
+    pickled_attachments = models.TextField(null=True, blank=True)
+    posted_on = models.DateTimeField()
+    updated_on = models.DateTimeField()
+    edits = models.PositiveIntegerField(default=0)
+    last_editor = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='+',
+                                    null=True, blank=True,
+                                    on_delete=models.SET_NULL)
+    last_editor_name = models.CharField(max_length=255, null=True, blank=True)
+    last_editor_slug = models.SlugField(max_length=255, null=True, blank=True)
+    is_reported = models.BooleanField(default=False, db_index=True)
+    is_moderated = models.BooleanField(default=False)
+    is_hidden = models.BooleanField(default=False)
+    is_protected = models.BooleanField(default=False)

+ 21 - 12
misago/threads/models/thread.py

@@ -3,24 +3,33 @@ from django.db import models
 from misago.conf import settings
 
 
-class Thread(object):#(models.Model):
-    forum = models.ForeignKey('Forum')
+class Thread(models.Model):
+    forum = models.ForeignKey('misago_forums.Forum')
     weight = models.PositiveIntegerField(default=0)
-    prefix = models.ForeignKey('ThreadPrefix', null=True, blank=True, on_delete=models.SET_NULL)
+    prefix = models.ForeignKey('misago_threads.Prefix', null=True, blank=True,
+                               on_delete=models.SET_NULL)
     name = models.CharField(max_length=255)
     slug = models.SlugField(max_length=255)
     replies = models.PositiveIntegerField(default=0)
     has_reported_posts = models.BooleanField(default=False)
     has_moderated_posts = models.BooleanField(default=False)
-    has_deleted_posts = models.BooleanField(default=False)
-    start = models.DateTimeField()
-    start_post = models.ForeignKey('Post', related_name='+', null=True, blank=True, on_delete=models.SET_NULL)
-    start_poster = models.ForeignKey('User', null=True, blank=True, on_delete=models.SET_NULL)
-    start_poster_name = models.CharField(max_length=255)
-    start_poster_slug = models.SlugField(max_length=255)
-    last = models.DateTimeField()
-    last_post = models.ForeignKey('Post', related_name='+', null=True, blank=True, on_delete=models.SET_NULL)
-    last_poster = models.ForeignKey('User', related_name='+', null=True, blank=True, on_delete=models.SET_NULL)
+    has_hidden_posts = models.BooleanField(default=False)
+    started_on = models.DateTimeField()
+    first_post = models.ForeignKey('misago_threads.Post', related_name='+',
+                                   null=True, blank=True,
+                                   on_delete=models.SET_NULL)
+    starter = models.ForeignKey(settings.AUTH_USER_MODEL,
+                                null=True, blank=True,
+                                on_delete=models.SET_NULL)
+    starter_name = models.CharField(max_length=255)
+    starter_slug = models.SlugField(max_length=255)
+    last_post_on = models.DateTimeField()
+    last_post = models.ForeignKey('misago_threads.Post', related_name='+',
+                                  null=True, blank=True,
+                                  on_delete=models.SET_NULL)
+    last_poster = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='+',
+                                    null=True, blank=True,
+                                    on_delete=models.SET_NULL)
     last_poster_name = models.CharField(max_length=255, null=True, blank=True)
     last_poster_slug = models.SlugField(max_length=255, null=True, blank=True)
     is_poll = models.BooleanField(default=False)