Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/apps/forums/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def delete(self, request, *args, **kwargs):
self.object = self.get_object()

if self.object.thread.forum.competition.created_by == request.user or \
request.user in self.object.thread.forum.competition.admins.all() or \
self.object.posted_by == request.user:

# If there are more posts in the thread, leave it around, otherwise delete it
Expand Down Expand Up @@ -129,7 +128,6 @@ def delete(self, request, *args, **kwargs):
self.object = self.get_object()

if self.object.forum.competition.created_by == request.user or \
request.user in self.object.forum.competition.admins.all() or \
self.object.started_by == request.user:

success_url = self.object.forum.get_absolute_url()
Expand Down Expand Up @@ -161,7 +159,7 @@ def pin_thread(request, thread_pk):
except Thread.DoesNotExist:
raise Http404()

if thread.forum.competition.created_by == request.user or request.user in thread.forum.competition.admins.all():
if thread.forum.competition.created_by == request.user or thread.started_by == request.user:
# Toggle pinned date on/off
thread.pinned_date = now() if thread.pinned_date is None else None
thread.save()
Expand Down
2 changes: 1 addition & 1 deletion src/apps/profiles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def get_full_name(self):
return self.name

def __str__(self):
return f'{self.username} | {self.email}'
return self.username

@property
def slug_url(self):
Expand Down
10 changes: 0 additions & 10 deletions src/static/css/forums.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@
.forum-panel .thread_title {
border-bottom: 1px solid #CCC;
}

.pin-button, .remove-button {
opacity: 0.5;
color: darkred;
}
.pin-button, .remove-button:hover {
opacity: 1;
cursor: pointer;
}

.pinned-thread-icon {
opacity: 0.5;
color: darkred;
Expand Down
47 changes: 47 additions & 0 deletions src/static/stylus/forum.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.forum-post
background-color #fff
padding 10px
width 80%
border-radius: 5px
box-shadow 0.5px 0.5px 2px gray

.post-header
display flex
justify-content flex-start

.post-user
margin-right 10px

.post-user-img
width 50px
height 50px
border-radius 50%
border 1px solid #000

.post-user-name-date
display flex
flex-direction column
justify-content center

.poster-name
font-size 18px

.posted-date
font-size 14px
color #aba8a8
line-height 1
margin-top 5px

.post-actions
margin-left auto
cursor pointer

.post-content
margin-left 60px
margin-right 60px
padding 10px
background-color #F5F5F5
border-radius: 2px

.forum-pin-icon
color #017BFE
1 change: 1 addition & 0 deletions src/static/stylus/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
@import "src/static/stylus/search.styl"
@import "src/static/stylus/simple_page.styl"
@import "src/static/stylus/toastr.styl"
@import "src/static/stylus/forum.styl"

2 changes: 2 additions & 0 deletions src/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Overpass+Mono&display=swap" rel="stylesheet">

<!-- Bootstrap -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">

<!-- Ours -->
<link rel="stylesheet" href="{% static "generated/output.css" %}">
Expand Down
12 changes: 2 additions & 10 deletions src/templates/forums/base_forum.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ <h1>{{ forum.competition.title }} Forum</h1>
</a>
{% elif 'new_post' not in request.path %}
<a href="{% url 'forums:forum_new_post' forum_pk=forum.pk thread_pk=thread.pk %}">
<button class="ui button primary">
Post in this thread
<button class="ui button green right floated">
<i class="icon plus"></i> Add new post
</button>
</a>
{% endif %}
Expand All @@ -47,14 +47,6 @@ <h1>{{ forum.competition.title }} Forum</h1>
{% block forum_content %}
{% endblock forum_content %}
</div>

{% if thread and 'new_post' not in request.path %}
<a href="{% url 'forums:forum_new_post' forum_pk=forum.pk thread_pk=thread.pk %}">
<button class="ui button primary">
Post in this thread
</button>
</a>
{% endif %}
</div>
</div>
</div>
Expand Down
32 changes: 29 additions & 3 deletions src/templates/forums/thread_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,36 @@
{% block forum_content %}

<div class="ui horizontal divider">{{ thread.title }}</div>
<div class="ui divided items form-content">
<div class="ui items form-content">
{% for post in ordered_posts %}
<div class="item">
<div class="content">
<div class="forum-post">
<!-- Header -->
<div class="post-header">
<div class="post-user">
{% if post.posted_by.photo %}
<img class="post-user-img" src="/static/img/user-avatar.png">
<!-- <img class="post-user-img" src="{{ post.posted_by.photo }}"> -->
{% else %}
<img class="post-user-img" src="/static/img/user-avatar.png">
{% endif %}
</div>
<div class="post-user-name-date">
<div class="poster-name">{{ post.posted_by }}</div>
<div class="posted-date">{{ post.date_created }}</div>
</div>
<div class="post-actions">
{% if thread.forum.competition.creator == request.user or post.posted_by == request.user %}
<i class="icon trash red remove-button" data-submission-pk="{{ post.pk }}"></i>
{% endif %}
</div>
</div>
<!-- Content -->
<div class="post-content">
<div class="markdown-content" data-content="{{ post.content }}"></div>
</div>
</div>
<!-- <div class="content">
{% if thread.forum.competition.creator == request.user or request.user in thread.forum.competition.admins.all or post.posted_by == request.user %}
<i class="remove-button glyphicon glyphicon-remove pull-right" data-submission-pk="{{ post.pk }}"></i>
{% endif %}
Expand All @@ -16,7 +42,7 @@
<div class="extra">
Posted by: <a href="{% url "profiles:user_profile" username=post.posted_by.slug %}">{{ post.posted_by }}</a> @ {{ post.date_created }}
</div>
</div>
</div> -->
</div>
{% endfor %}
</div>
Expand Down
24 changes: 12 additions & 12 deletions src/templates/forums/thread_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

{% block forum_content %}
<div class="ui horizontal divider">Threads</div>

{% if forum.threads.all %}
<table class="ui single line table threads_list">
<thead>
Expand All @@ -23,32 +22,33 @@
<th>
Posts
</th>
{% if forum.competition.creator == request.user %}
<th>

</th>
{% endif %}
<th>
Actions
</th>
</tr>
</thead>
<tbody>
{% for thread in thread_list_sorted %}
<tr data-href="{% url 'forums:forum_thread_detail' forum_pk=forum.pk thread_pk=thread.pk %}" class="clickable-row">
<tr>
<td>
{% if thread.pinned_date %}
<i class="pinned-thread-icon glyphicon glyphicon-pushpin" data-thread-pk="{{ thread.pk }}"></i>
<a href="{% url 'forums:forum_thread_pin' thread_pk=thread.pk %}"><i class="forum-pin-icon bi bi-pin-angle-fill" data-thread-pk="{{ thread.pk }}"></i></a>
{% endif %}

{{ thread.title }}
<!-- Title -->
<a href="{% url 'forums:forum_thread_detail' forum_pk=forum.pk thread_pk=thread.pk %}">{{ thread.title }}</a>
</td>
<td>{{ thread.started_by }}</td>
<td>{{ thread.date_created|date:"M d, Y" }}</td>
<td>{{ thread.last_post_date|timesince }}</td>
{# date:"g:iA M d" #}
<td>{{ thread.posts.count }}</td>
{% if forum.competition.creator == request.user or request.user in forum.competition.admins.all %}
{% if thread.started_by == request.user %}
<td>
<a href="{% url "forum_thread_pin" thread_pk=thread.pk %}"><i class="pin-button glyphicon glyphicon-pushpin" data-thread-pk="{{ thread.pk }}"></i></a>
<i class="remove-button glyphicon glyphicon-remove" data-thread-pk="{{ thread.pk }}"></i>
<i class="remove-button red icon trash" data-thread-pk="{{ thread.pk }}"></i>
{% if not thread.pinned_date %}
<a href="{% url 'forums:forum_thread_pin' thread_pk=thread.pk %}"><i class="forum-pin-icon bi bi-pin-angle" data-thread-pk="{{ thread.pk }}"></i></a>
{% endif %}
</td>
{% endif %}
</tr>
Expand Down