diff --git a/core/static/core/style.css b/core/static/core/style.css index 240347c1..8f3aaf34 100644 --- a/core/static/core/style.css +++ b/core/static/core/style.css @@ -11,6 +11,20 @@ a { } a:hover { color: #7FDBFF; } a:active { color: #007BE6; } +.ib { + display: inline-block; + padding: 2px; + margin: 2px; +} +.w_big { + width: 75%; +} +.w_medium { + width: 45%; +} +.w_small { + width: 20%; +} /*--------------------------------HEADER-------------------------------*/ #logo { margin-left: 5%; @@ -377,7 +391,8 @@ textarea { color: black; } .topic a:hover, .forum a:hover, .category a:hover { - color: #242424; + color: #424242; + text-decoration: underline; } .topic { border: solid skyblue 1px; @@ -403,6 +418,7 @@ textarea { .msg_author { display: inline-block; width: 19%; + text-align: center; } .msg_author img { max-width: 80%; diff --git a/forum/admin.py b/forum/admin.py index 8c38f3f3..162589b1 100644 --- a/forum/admin.py +++ b/forum/admin.py @@ -1,3 +1,7 @@ from django.contrib import admin -# Register your models here. +from forum.models import * + +admin.site.register(Forum) +admin.site.register(ForumTopic) +admin.site.register(ForumMessage) diff --git a/forum/models.py b/forum/models.py index 59605114..a69e5b0d 100644 --- a/forum/models.py +++ b/forum/models.py @@ -52,6 +52,24 @@ class Forum(models.Model): p = p.parent return l + def get_topic_number(self): + number = self.topics.all().count() + for c in self.children.all(): + number += c.get_topic_number() + return number + + def get_last_message(self): + last_msg = None + for m in ForumMessage.objects.order_by('-id'): + forum = m.topic.forum + if self in (forum.get_parent_list() + [forum]): + return m + last_msg = m + try: + pass + except: pass + return last_msg + class ForumTopic(models.Model): forum = models.ForeignKey(Forum, related_name='topics') author = models.ForeignKey(User, related_name='forum_topics') @@ -93,7 +111,7 @@ class ForumMessage(models.Model): return self.topic.is_owned_by(user) or user.id == self.author.id def can_be_edited_by(self, user): - return user.can_edit(self.topic) + return user.is_owner(self.topic) def can_be_viewed_by(self, user): return user.can_view(self.topic) diff --git a/forum/templates/forum/forum.jinja b/forum/templates/forum/forum.jinja index 9a159082..624b13f2 100644 --- a/forum/templates/forum/forum.jinja +++ b/forum/templates/forum/forum.jinja @@ -3,13 +3,13 @@ {% from 'core/macros.jinja' import user_profile_link %} {% block content %} -
+
- Edit -
- -{{ t.description }}
+{{ t.description }}
+ + {% if user.can_edit(t) %} +Last message by {{ user_profile_link(last_msg.author) }} at {{ last_msg.date|date(DATETIME_FORMAT) }} {{ - last_msg.date|time(DATETIME_FORMAT) }}
+- Edit -
- {% if not forum.is_category %} - - {% endif %} -{{ forum.description }}
+{{ forum.description }}
+ {% if not forum.is_category %} + + {% else %} +