punkweb-bb 0.1.4__py3-none-any.whl → 0.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. punkweb_bb/__pycache__/forms.cpython-311.pyc +0 -0
  2. punkweb_bb/__pycache__/models.cpython-311.pyc +0 -0
  3. punkweb_bb/__pycache__/settings.cpython-311.pyc +0 -0
  4. punkweb_bb/__pycache__/tests.cpython-311.pyc +0 -0
  5. punkweb_bb/__pycache__/urls.cpython-311.pyc +0 -0
  6. punkweb_bb/__pycache__/utils.cpython-311.pyc +0 -0
  7. punkweb_bb/__pycache__/views.cpython-311.pyc +0 -0
  8. punkweb_bb/forms.py +40 -7
  9. punkweb_bb/migrations/0003_alter_thread_options.py +23 -0
  10. punkweb_bb/migrations/__pycache__/0003_alter_thread_options.cpython-311.pyc +0 -0
  11. punkweb_bb/models.py +25 -0
  12. punkweb_bb/settings.py +1 -0
  13. punkweb_bb/static/punkweb_bb/css/category-form.css +24 -0
  14. punkweb_bb/static/punkweb_bb/css/index.css +6 -0
  15. punkweb_bb/static/punkweb_bb/css/punkweb.css +155 -8
  16. punkweb_bb/static/punkweb_bb/css/shoutbox.css +13 -2
  17. punkweb_bb/static/punkweb_bb/css/subcategory-form.css +24 -0
  18. punkweb_bb/static/punkweb_bb/css/subcategory.css +12 -0
  19. punkweb_bb/static/punkweb_bb/css/thread.css +20 -1
  20. punkweb_bb/static/punkweb_bb/css/variables.css +1 -0
  21. punkweb_bb/static/punkweb_bb/editor/bbcode-editor.js +1 -1
  22. punkweb_bb/templates/punkweb_bb/base.html +6 -0
  23. punkweb_bb/templates/punkweb_bb/category_create.html +50 -0
  24. punkweb_bb/templates/punkweb_bb/category_update.html +53 -0
  25. punkweb_bb/templates/punkweb_bb/index.html +43 -2
  26. punkweb_bb/templates/punkweb_bb/login.html +1 -0
  27. punkweb_bb/templates/punkweb_bb/members.html +1 -0
  28. punkweb_bb/templates/punkweb_bb/partials/category_delete.html +11 -0
  29. punkweb_bb/templates/punkweb_bb/partials/shout_delete.html +11 -0
  30. punkweb_bb/templates/punkweb_bb/partials/subcategory_delete.html +11 -0
  31. punkweb_bb/templates/punkweb_bb/profile.html +1 -0
  32. punkweb_bb/templates/punkweb_bb/settings.html +1 -0
  33. punkweb_bb/templates/punkweb_bb/shoutbox/shout_list.html +18 -4
  34. punkweb_bb/templates/punkweb_bb/signup.html +1 -0
  35. punkweb_bb/templates/punkweb_bb/subcategory.html +31 -6
  36. punkweb_bb/templates/punkweb_bb/subcategory_create.html +53 -0
  37. punkweb_bb/templates/punkweb_bb/subcategory_update.html +56 -0
  38. punkweb_bb/templates/punkweb_bb/thread.html +94 -22
  39. punkweb_bb/templates/punkweb_bb/thread_create.html +2 -0
  40. punkweb_bb/templatetags/__pycache__/can_delete.cpython-311.pyc +0 -0
  41. punkweb_bb/templatetags/__pycache__/can_edit.cpython-311.pyc +0 -0
  42. punkweb_bb/templatetags/__pycache__/can_post.cpython-311.pyc +0 -0
  43. punkweb_bb/templatetags/can_delete.py +8 -0
  44. punkweb_bb/templatetags/can_edit.py +8 -0
  45. punkweb_bb/templatetags/can_post.py +8 -0
  46. punkweb_bb/tests.py +5 -5
  47. punkweb_bb/urls.py +29 -0
  48. punkweb_bb/utils.py +17 -0
  49. punkweb_bb/views.py +258 -45
  50. {punkweb_bb-0.1.4.dist-info → punkweb_bb-0.2.1.dist-info}/METADATA +2 -2
  51. {punkweb_bb-0.1.4.dist-info → punkweb_bb-0.2.1.dist-info}/RECORD +54 -35
  52. {punkweb_bb-0.1.4.dist-info → punkweb_bb-0.2.1.dist-info}/LICENSE +0 -0
  53. {punkweb_bb-0.1.4.dist-info → punkweb_bb-0.2.1.dist-info}/WHEEL +0 -0
  54. {punkweb_bb-0.1.4.dist-info → punkweb_bb-0.2.1.dist-info}/top_level.txt +0 -0
@@ -31,7 +31,39 @@
31
31
  </colgroup>
32
32
  <thead>
33
33
  <tr>
34
- <th><a href="{{category.get_absolute_url}}">{{category.name}}</a></th>
34
+ <th>
35
+ <div class="index__category__title">
36
+ <a href="{{category.get_absolute_url}}">{{category.name}}</a>
37
+ {% if perms.punkweb_bb.add_subcategory %}
38
+ <a
39
+ class="pw-icon-button default rounded sm"
40
+ href="{% url 'punkweb_bb:subcategory_create' category.slug %}"
41
+ title="Create subcategory"
42
+ >
43
+ <span class="material-symbols-outlined">add</span>
44
+ </a>
45
+ {% endif %}
46
+ {% if perms.punkweb_bb.change_category %}
47
+ <a
48
+ class="pw-icon-button default rounded sm"
49
+ href="{% url 'punkweb_bb:category_update' category.slug %}"
50
+ title="Edit category"
51
+ >
52
+ <span class="material-symbols-outlined">edit</span>
53
+ </a>
54
+ {% endif %}
55
+ {% if perms.punkweb_bb.delete_category %}
56
+ <a
57
+ class="pw-icon-button default danger rounded sm"
58
+ title="Delete category"
59
+ hx-get="{% url 'punkweb_bb:category_delete' category.slug %}"
60
+ hx-target="#modal-portal"
61
+ >
62
+ <span class="material-symbols-outlined">delete</span>
63
+ </a>
64
+ {% endif %}
65
+ </div>
66
+ </th>
35
67
  <th>Threads</th>
36
68
  <th>Posts</th>
37
69
  <th></th>
@@ -43,7 +75,7 @@
43
75
  <td>
44
76
  <a href="{{subcategory.get_absolute_url}}" title="{{subcategory.name}}">{{subcategory.name}}</a>
45
77
  <div>
46
- {{subcategory.description}}
78
+ {{subcategory.description.rendered}}
47
79
  </div>
48
80
  </td>
49
81
  <td>{{subcategory.thread_count}}</td>
@@ -110,6 +142,15 @@
110
142
  </div>
111
143
  </div>
112
144
  {% endfor %}
145
+ {% if perms.punkweb_bb.add_category %}
146
+ <a
147
+ class="pw-icon-button raised primary rounded"
148
+ href="{% url 'punkweb_bb:category_create' %}"
149
+ title="Create category"
150
+ >
151
+ <span class="material-symbols-outlined">add</span>
152
+ </a>
153
+ {% endif %}
113
154
  </div>
114
155
  <div class="index__sidebar">
115
156
  <div class="pw-card fluid">
@@ -2,6 +2,7 @@
2
2
  {% load static %}
3
3
 
4
4
  {% block title_prefix %}Login | {% endblock%}
5
+ {% block og_title_prefix %}Login | {% endblock %}
5
6
 
6
7
  {% block extra_head %}
7
8
  <link rel="stylesheet" href="{% static 'punkweb_bb/css/login.css' %}" />
@@ -2,6 +2,7 @@
2
2
  {% load static %}
3
3
 
4
4
  {% block title_prefix %}Members | {% endblock%}
5
+ {% block og_title_prefix %}Members | {% endblock %}
5
6
 
6
7
  {% block extra_head %}
7
8
  <link rel="stylesheet" href="{% static 'punkweb_bb/css/members.css' %}" />
@@ -0,0 +1,11 @@
1
+ {% extends 'punkweb_bb/base_modal.html' %}
2
+
3
+ {% block title %}Delete Category{% endblock %}
4
+
5
+ {% block content %}
6
+ <p>Are you sure you want to delete this category? This action cannot be undone!</p>
7
+ <div class="modal__actions">
8
+ <button class="modal__cancel pw-button default">Cancel</button>
9
+ <button class="pw-button raised danger" hx-delete="{% url 'punkweb_bb:category_delete' category.slug %}">Delete</button>
10
+ </div>
11
+ {% endblock %}
@@ -0,0 +1,11 @@
1
+ {% extends 'punkweb_bb/base_modal.html' %}
2
+
3
+ {% block title %}Delete Shout{% endblock %}
4
+
5
+ {% block content %}
6
+ <p>Are you sure you want to delete this shout? This action cannot be undone!</p>
7
+ <div class="modal__actions">
8
+ <button class="modal__cancel pw-button default">Cancel</button>
9
+ <button class="pw-button raised danger" hx-delete="{% url 'punkweb_bb:shout_delete' shout.id %}">Delete</button>
10
+ </div>
11
+ {% endblock %}
@@ -0,0 +1,11 @@
1
+ {% extends 'punkweb_bb/base_modal.html' %}
2
+
3
+ {% block title %}Delete Subcategory{% endblock %}
4
+
5
+ {% block content %}
6
+ <p>Are you sure you want to delete this subcategory? This action cannot be undone!</p>
7
+ <div class="modal__actions">
8
+ <button class="modal__cancel pw-button default">Cancel</button>
9
+ <button class="pw-button raised danger" hx-delete="{% url 'punkweb_bb:subcategory_delete' subcategory.slug %}">Delete</button>
10
+ </div>
11
+ {% endblock %}
@@ -2,6 +2,7 @@
2
2
  {% load static %}
3
3
 
4
4
  {% block title_prefix %}{{ user.username }} | {% endblock%}
5
+ {% block og_title_prefix %}{{ user.username }} | {% endblock %}
5
6
 
6
7
  {% block extra_head %}
7
8
  <link rel="stylesheet" href="{% static 'punkweb_bb/css/profile.css' %}">
@@ -2,6 +2,7 @@
2
2
  {% load static %}
3
3
 
4
4
  {% block title_prefix %}Settings | {% endblock %}
5
+ {% block og_title_prefix %}Settings | {% endblock %}
5
6
 
6
7
  {% block extra_head %}
7
8
  {{form.media.css}}
@@ -1,9 +1,23 @@
1
- {% load shoutbox_bbcode %}
1
+ {% load shoutbox_bbcode can_delete %}
2
2
 
3
3
  {% for shout in shouts %}
4
4
  <div class="shoutbox__shout">
5
- <span>{{shout.created_at|date:'g:i A'}}</span>
6
- <span><a href="{% url 'punkweb_bb:profile' shout.user.id %}">{{shout.user.username}}</a>: </span>
7
- <span>{{ shout.content | safe | shoutbox_bbcode }}</span>
5
+ <div class="shoutbox__shout__content">
6
+ <span>{{shout.created_at|date:'g:i A'}}</span>
7
+ <span><a href="{% url 'punkweb_bb:profile' shout.user.id %}">{{shout.user.username}}</a>: </span>
8
+ <span>{{ shout.content | safe | shoutbox_bbcode }}</span>
9
+ </div>
10
+ {% if shout|can_delete:request.user %}
11
+ <div class="shoutbox__shout__actions">
12
+ <button
13
+ class="pw-icon-button default danger sm"
14
+ title="Delete"
15
+ hx-get="{% url 'punkweb_bb:shout_delete' shout.id %}"
16
+ hx-target="#modal-portal"
17
+ >
18
+ <span class="material-symbols-outlined">delete</span>
19
+ </button>
20
+ </div>
21
+ {% endif %}
8
22
  </div>
9
23
  {% endfor %}
@@ -2,6 +2,7 @@
2
2
  {% load static %}
3
3
 
4
4
  {% block title_prefix %}Sign Up | {% endblock%}
5
+ {% block og_title_prefix %}Sign Up | {% endblock %}
5
6
 
6
7
  {% block extra_head %}
7
8
  <link rel="stylesheet" href="{% static 'punkweb_bb/css/login.css' %}" />
@@ -1,7 +1,8 @@
1
1
  {% extends 'punkweb_bb/base.html' %}
2
- {% load static humanize_int %}
2
+ {% load static humanize_int can_post %}
3
3
 
4
4
  {% block title_prefix %}{{subcategory.name}} | {% endblock%}
5
+ {% block og_title_prefix %}{{subcategory.name}} | {% endblock %}
5
6
 
6
7
  {% block extra_head %}
7
8
  <link rel="stylesheet" href="{% static 'punkweb_bb/css/subcategory.css' %}" />
@@ -24,21 +25,45 @@
24
25
  </nav>
25
26
 
26
27
  <div class="subcategory__header">
27
- <h1>{{subcategory.name}}</h1>
28
- {% if request.user.is_authenticated %}
29
- {% if not subcategory.staff_post_only or request.user.is_staff %}
28
+ <div class="subcategory__header__name">
29
+ <h1>{{subcategory.name}}</h1>
30
+ {% if perms.punkweb_bb.change_subcategory or perms.punkweb_bb.delete_subcategory %}
31
+ <div class="subcategory__header__actions">
32
+ {% if perms.punkweb_bb.change_subcategory %}
33
+ <a
34
+ class="pw-icon-button default rounded"
35
+ href="{% url 'punkweb_bb:subcategory_update' subcategory.slug %}"
36
+ title="Edit subcategory"
37
+ >
38
+ <span class="material-symbols-outlined">edit</span>
39
+ </a>
40
+ {% endif %}
41
+ {% if perms.punkweb_bb.delete_subcategory %}
42
+ <a
43
+ class="pw-icon-button default rounded danger"
44
+ title="Delete subcategory"
45
+ hx-get="{% url 'punkweb_bb:subcategory_delete' subcategory.slug %}"
46
+ hx-target="#modal-portal"
47
+ >
48
+ <span class="material-symbols-outlined">delete</span>
49
+ </a>
50
+ {% endif %}
51
+ </div>
52
+ {% endif %}
53
+ </div>
54
+
55
+ {% if subcategory|can_post:request.user %}
30
56
  <a class="pw-button ghost primary" href="{% url 'punkweb_bb:thread_create' subcategory.slug %}">Create Thread</a>
31
57
  {% else %}
32
58
  <button
33
59
  class="pw-button ghost primary"
34
60
  disabled
35
61
  href="{% url 'punkweb_bb:thread_create' subcategory.slug %}"
36
- title="Only staff can create threads in this subcategory"
62
+ title="You do not have permission to create a thread in this subcategory."
37
63
  >
38
64
  Create Thread
39
65
  </button>
40
66
  {% endif %}
41
- {% endif %}
42
67
  </div>
43
68
 
44
69
  <div class="pw-card fluid margin">
@@ -0,0 +1,53 @@
1
+ {% extends 'punkweb_bb/base.html' %}
2
+ {% load static %}
3
+
4
+ {% block title_prefix %}Create Subcategory | {% endblock %}
5
+
6
+ {% block extra_head %}
7
+ {{form.media.css}}
8
+ <link rel="stylesheet" href="{% static 'punkweb_bb/css/subcategory-form.css' %}" />
9
+ {% endblock %}
10
+
11
+ {% block content %}
12
+
13
+ <nav>
14
+ <ul class="pw-breadcrumb">
15
+ <li class="pw-breadcrumb-item">
16
+ <a href="{% url 'punkweb_bb:index' %}">Home</a>
17
+ </li>
18
+ <li class="pw-breadcrumb-item">
19
+ <a href="{{category.get_absolute_url}}">{{category.name}}</a>
20
+ </li>
21
+ <li class="pw-breadcrumb-item active">
22
+ Create Subcategory
23
+ </li>
24
+ </ul>
25
+ </nav>
26
+
27
+ <div class="pw-card fluid">
28
+ <div class="pw-card-header">Create Subcategory</div>
29
+ <div class="pw-card-content">
30
+ <form class="subcategoryForm" action="{% url 'punkweb_bb:subcategory_create' category.slug %}" method="post">
31
+ {% csrf_token %}
32
+ {% for field in form %}
33
+ <div class="subcategoryForm__field">
34
+ <label class="pw-input-label" for="{{ field.id_for_label }}">{{ field.label }}</label>
35
+ {{ field }}
36
+ </div>
37
+ {% endfor %}
38
+ {% if form.non_field_errors %}
39
+ {{ form.non_field_errors }}
40
+ {% endif %}
41
+ <div class="subcategoryForm__actions">
42
+ <a class="pw-button default" href="{% url 'punkweb_bb:index' %}" type="submit">Cancel</a>
43
+ <button class="pw-button raised primary" type="submit">Create</button>
44
+ </div>
45
+ </form>
46
+ </div>
47
+ </div>
48
+
49
+ {% endblock %}
50
+
51
+ {% block extra_script %}
52
+ {{form.media.js}}
53
+ {% endblock %}
@@ -0,0 +1,56 @@
1
+ {% extends 'punkweb_bb/base.html' %}
2
+ {% load static %}
3
+
4
+ {% block title_prefix %}Edit Subcategory | {% endblock %}
5
+
6
+ {% block extra_head %}
7
+ {{form.media.css}}
8
+ <link rel="stylesheet" href="{% static 'punkweb_bb/css/subcategory-form.css' %}" />
9
+ {% endblock %}
10
+
11
+ {% block content %}
12
+
13
+ <nav>
14
+ <ul class="pw-breadcrumb">
15
+ <li class="pw-breadcrumb-item">
16
+ <a href="{% url 'punkweb_bb:index' %}">Home</a>
17
+ </li>
18
+ <li class="pw-breadcrumb-item">
19
+ <a href="{{subcategory.category.get_absolute_url}}">{{subcategory.category.name}}</a>
20
+ </li>
21
+ <li class="pw-breadcrumb-item">
22
+ <a href="{{subcategory.get_absolute_url}}">{{subcategory.name}}</a>
23
+ </li>
24
+ <li class="pw-breadcrumb-item active">
25
+ Edit
26
+ </li>
27
+ </ul>
28
+ </nav>
29
+
30
+ <div class="pw-card fluid">
31
+ <div class="pw-card-header">Edit Subcategory</div>
32
+ <div class="pw-card-content">
33
+ <form class="subcategoryForm" action="{% url 'punkweb_bb:subcategory_update' subcategory.slug %}" method="post">
34
+ {% csrf_token %}
35
+ {% for field in form %}
36
+ <div class="subcategoryForm__field">
37
+ <label class="pw-input-label" for="{{ field.id_for_label }}">{{ field.label }}</label>
38
+ {{ field }}
39
+ </div>
40
+ {% endfor %}
41
+ {% if form.non_field_errors %}
42
+ {{ form.non_field_errors }}
43
+ {% endif %}
44
+ <div class="subcategoryForm__actions">
45
+ <a class="pw-button default" href="{{subcategory.get_absolute_url}}">Cancel</a>
46
+ <button class="pw-button raised primary" type="submit">Save</button>
47
+ </div>
48
+ </form>
49
+ </div>
50
+ </div>
51
+
52
+ {% endblock %}
53
+
54
+ {% block extra_script %}
55
+ {{form.media.js}}
56
+ {% endblock %}
@@ -1,9 +1,12 @@
1
1
  {% extends 'punkweb_bb/base.html' %}
2
- {% load static %}
2
+ {% load static can_delete can_edit can_post %}
3
3
 
4
4
  {% block title_prefix %}{{thread.title}} | {% endblock %}
5
+ {% block og_title_prefix %}{{thread.title}} | {% endblock %}
5
6
 
6
7
  {% block extra_head %}
8
+ <meta name="description" content="{{thread.content.rendered|striptags|truncatechars:120}}" />
9
+ <meta property="og:description" content="{{thread.content.rendered|striptags|truncatechars:120}}" />
7
10
  <link rel="stylesheet" href="{% static 'punkweb_bb/css/post-form.css' %}" />
8
11
  <link rel="stylesheet" href="{% static 'punkweb_bb/css/thread.css' %}" />
9
12
  <link rel="stylesheet" href="{% static 'punkweb_bb/css/thread-form.css' %}" />
@@ -67,25 +70,74 @@
67
70
  <div class="thread__user__info__value">{{thread.user.profile.post_count}}</div>
68
71
  </div>
69
72
  </div>
73
+ {% if thread.user.groups.all|length > 0 %}
74
+ <div class="thread__user__groups">
75
+ {% for group in thread.user.groups.all %}
76
+ <div class="thread__user__group">{{group.name}}</div>
77
+ {% endfor %}
78
+ </div>
79
+ {% endif %}
70
80
  </div>
71
81
  <div class="thread__main">
72
82
  <div class="thread__content">
73
83
  {{thread.content.rendered}}
74
84
  </div>
85
+ {% if thread|can_delete:request.user or thread|can_edit:request.user or perms.punkweb_bb.pin_thread or perms.punkweb_bb.close_thread %}
86
+ <div class="thread__actions">
87
+ {% if perms.punkweb_bb.pin_thread %}
88
+ <a
89
+ class="pw-icon-button default rounded"
90
+ title="{% if thread.is_pinned %}Unpin{% else %}Pin{% endif %}"
91
+ hx-get="{% url 'punkweb_bb:thread_pin' thread.id %}"
92
+ hx-swap="none"
93
+ >
94
+ {% if thread.is_pinned %}
95
+ <span class="material-symbols-outlined">keep_off</span>
96
+ {% else %}
97
+ <span class="material-symbols-outlined">keep</span>
98
+ {% endif %}
99
+ </a>
100
+ {% endif %}
101
+ {% if perms.punkweb_bb.close_thread %}
102
+ <a
103
+ class="pw-icon-button default rounded"
104
+ title="{% if thread.is_closed %}Reopen{% else %}Close{% endif %}"
105
+ hx-get="{% url 'punkweb_bb:thread_close' thread.id %}"
106
+ hx-swap="none"
107
+ >
108
+ {% if thread.is_closed %}
109
+ <span class="material-symbols-outlined">lock_open</span>
110
+ {% else %}
111
+ <span class="material-symbols-outlined">lock</span>
112
+ {% endif %}
113
+ </a>
114
+ {% endif %}
115
+ {% if thread|can_edit:request.user %}
116
+ <a
117
+ class="pw-icon-button default rounded"
118
+ href="{% url 'punkweb_bb:thread_update' thread.id %}"
119
+ title="Edit"
120
+ >
121
+ <span class="material-symbols-outlined">edit</span>
122
+ </a>
123
+ {% endif %}
124
+ {% if thread|can_delete:request.user %}
125
+ <a
126
+ class="pw-icon-button default rounded danger"
127
+ title="Delete"
128
+ hx-get="{% url 'punkweb_bb:thread_delete' thread.id %}"
129
+ hx-target="#modal-portal"
130
+ >
131
+ <span class="material-symbols-outlined">delete</span>
132
+ </a>
133
+ {% endif %}
134
+ </div>
135
+ {% endif %}
75
136
  {% if thread.user.profile.signature.rendered %}
76
137
  <div class="thread__signature">
77
138
  {{thread.user.profile.signature.rendered}}
78
139
  </div>
79
140
  {% endif %}
80
- {% if thread.user == request.user %}
81
- <div class="thread__actions">
82
- <a class="pw-button ghost sm" href="{% url 'punkweb_bb:thread_update' thread.id %}">Edit</a>
83
- <a class="pw-button ghost danger sm" hx-get="{% url 'punkweb_bb:thread_delete' thread.id %}"
84
- hx-target="#modal-portal">
85
- Delete
86
- </a>
87
- </div>
88
- {% endif %}
89
141
  </div>
90
142
  </div>
91
143
  </div>
@@ -128,25 +180,47 @@
128
180
  <div class="thread__user__info__value">{{post.user.profile.post_count}}</div>
129
181
  </div>
130
182
  </div>
183
+ {% if post.user.groups.all|length > 0 %}
184
+ <div class="thread__user__groups">
185
+ {% for group in post.user.groups.all %}
186
+ <div class="thread__user__group">{{group.name}}</div>
187
+ {% endfor %}
188
+ </div>
189
+ {% endif %}
131
190
  </div>
132
191
  <div class="thread__main">
133
192
  <div class="thread__content">
134
193
  {{post.content.rendered}}
135
194
  </div>
195
+ {% if post|can_delete:request.user or post|can_edit:request.user %}
196
+ <div class="thread__actions">
197
+ {% if post|can_edit:request.user %}
198
+ <a
199
+ class="pw-icon-button default rounded"
200
+ title="Edit"
201
+ hx-get="{% url 'punkweb_bb:post_update' post.id %}"
202
+ hx-target="#modal-portal"
203
+ >
204
+ <span class="material-symbols-outlined">edit</span>
205
+ </a>
206
+ {% endif %}
207
+ {% if post|can_delete:request.user %}
208
+ <a
209
+ class="pw-icon-button default rounded danger"
210
+ title="Delete"
211
+ hx-get="{% url 'punkweb_bb:post_delete' post.id %}"
212
+ hx-target="#modal-portal"
213
+ >
214
+ <span class="material-symbols-outlined">delete</span>
215
+ </a>
216
+ {% endif %}
217
+ </div>
218
+ {% endif %}
136
219
  {% if post.user.profile.signature.rendered %}
137
220
  <div class="thread__signature">
138
221
  {{post.user.profile.signature.rendered}}
139
222
  </div>
140
223
  {% endif %}
141
- {% if post.user == request.user %}
142
- <div class="thread__actions">
143
- <a class="pw-button ghost sm" hx-get="{% url 'punkweb_bb:post_update' post.id %}" hx-target="#modal-portal">Edit</a>
144
- <a class="pw-button ghost danger sm" hx-get="{% url 'punkweb_bb:post_delete' post.id %}"
145
- hx-target="#modal-portal">
146
- Delete
147
- </a>
148
- </div>
149
- {% endif %}
150
224
  </div>
151
225
  </div>
152
226
  </div>
@@ -198,8 +272,7 @@
198
272
  </nav>
199
273
  {% endif %}
200
274
 
201
- {% if request.user.is_authenticated %}
202
- {% if not thread.is_closed %}
275
+ {% if thread|can_post:request.user %}
203
276
  <div class="pw-card fluid margin">
204
277
  <div class="pw-card-header">Reply to thread</div>
205
278
  <div class="pw-card-content">
@@ -229,6 +302,5 @@
229
302
  </div>
230
303
  </div>
231
304
  {% endif %}
232
- {% endif %}
233
305
 
234
306
  {% endblock %}
@@ -2,6 +2,7 @@
2
2
  {% load static %}
3
3
 
4
4
  {% block title_prefix %}Create Thread | {% endblock %}
5
+ {% block og_title_prefix %}Create Thread | {% endblock %}
5
6
 
6
7
  {% block extra_head %}
7
8
  {{form.media.css}}
@@ -42,6 +43,7 @@
42
43
  {{ form.non_field_errors }}
43
44
  {% endif %}
44
45
  <div class="threadForm__actions">
46
+ <a class="pw-button default" href="{{subcategory.get_absolute_url}}" type="submit">Cancel</a>
45
47
  <button class="pw-button raised primary" type="submit">Create Thread</button>
46
48
  </div>
47
49
  </form>
@@ -0,0 +1,8 @@
1
+ from django import template
2
+
3
+ register = template.Library()
4
+
5
+
6
+ @register.filter
7
+ def can_delete(obj, user):
8
+ return obj.can_delete(user)
@@ -0,0 +1,8 @@
1
+ from django import template
2
+
3
+ register = template.Library()
4
+
5
+
6
+ @register.filter
7
+ def can_edit(obj, user):
8
+ return obj.can_edit(user)
@@ -0,0 +1,8 @@
1
+ from django import template
2
+
3
+ register = template.Library()
4
+
5
+
6
+ @register.filter
7
+ def can_post(obj, user):
8
+ return obj.can_post(user)
punkweb_bb/tests.py CHANGED
@@ -474,7 +474,7 @@ class ThreadCreateViewTestCase(TestCase):
474
474
  self.client.force_login(self.user)
475
475
  response = self.client.get(self.staff_only_url)
476
476
 
477
- self.assertRedirects(response, self.staff_subcategory.get_absolute_url())
477
+ self.assertEqual(response.status_code, 403)
478
478
 
479
479
 
480
480
  class ThreadViewTestCase(TestCase):
@@ -522,7 +522,7 @@ class ThreadUpdateViewTestCase(TestCase):
522
522
  def test_is_author(self):
523
523
  self.client.force_login(self.other_user)
524
524
  response = self.client.get(self.url)
525
- self.assertEqual(response.status_code, 404)
525
+ self.assertEqual(response.status_code, 403)
526
526
 
527
527
  self.client.force_login(self.user)
528
528
  response = self.client.get(self.url)
@@ -571,7 +571,7 @@ class ThreadDeleteViewTestCase(TestCase):
571
571
  def test_is_author(self):
572
572
  self.client.force_login(self.other_user)
573
573
  response = self.client.get(self.url)
574
- self.assertEqual(response.status_code, 404)
574
+ self.assertEqual(response.status_code, 403)
575
575
 
576
576
  self.client.force_login(self.user)
577
577
  response = self.client.get(self.url)
@@ -653,7 +653,7 @@ class PostUpdateViewTestCase(TestCase):
653
653
  def test_is_author(self):
654
654
  self.client.force_login(self.other_user)
655
655
  response = self.client.get(self.url)
656
- self.assertEqual(response.status_code, 404)
656
+ self.assertEqual(response.status_code, 403)
657
657
 
658
658
  self.client.force_login(self.user)
659
659
  response = self.client.get(self.url)
@@ -703,7 +703,7 @@ class PostDeleteViewTestCase(TestCase):
703
703
  def test_is_author(self):
704
704
  self.client.force_login(self.other_user)
705
705
  response = self.client.get(self.url)
706
- self.assertEqual(response.status_code, 404)
706
+ self.assertEqual(response.status_code, 403)
707
707
 
708
708
  self.client.force_login(self.user)
709
709
  response = self.client.get(self.url)
punkweb_bb/urls.py CHANGED
@@ -11,11 +11,37 @@ urlpatterns = [
11
11
  path("settings/", views.settings_view, name="settings"),
12
12
  path("members/", views.members_view, name="members"),
13
13
  path("members/<path:user_id>/", views.profile_view, name="profile"),
14
+ path("create-category/", views.category_create_view, name="category_create"),
15
+ path(
16
+ "category/<str:category_slug>/update/",
17
+ views.category_update_view,
18
+ name="category_update",
19
+ ),
20
+ path(
21
+ "category/<str:category_slug>/delete/",
22
+ views.category_delete_view,
23
+ name="category_delete",
24
+ ),
14
25
  path(
15
26
  "subcategory/<str:subcategory_slug>/",
16
27
  views.subcategory_view,
17
28
  name="subcategory",
18
29
  ),
30
+ path(
31
+ "category/<str:category_slug>/create-subcategory/",
32
+ views.subcategory_create_view,
33
+ name="subcategory_create",
34
+ ),
35
+ path(
36
+ "subcategory/<str:subcategory_slug>/update/",
37
+ views.subcategory_update_view,
38
+ name="subcategory_update",
39
+ ),
40
+ path(
41
+ "subcategory/<str:subcategory_slug>/delete/",
42
+ views.subcategory_delete_view,
43
+ name="subcategory_delete",
44
+ ),
19
45
  path(
20
46
  "subcategory/<str:subcategory_slug>/create-thread/",
21
47
  views.thread_create_view,
@@ -33,9 +59,12 @@ urlpatterns = [
33
59
  views.post_create_view,
34
60
  name="post_create",
35
61
  ),
62
+ path("thread/<str:thread_id>/pin/", views.thread_pin_view, name="thread_pin"),
63
+ path("thread/<str:thread_id>/close/", views.thread_close_view, name="thread_close"),
36
64
  path("post/<str:post_id>/delete/", views.post_delete_view, name="post_delete"),
37
65
  path("post/<str:post_id>/update/", views.post_update_view, name="post_update"),
38
66
  path("shout-list/", views.shout_list_view, name="shout_list"),
39
67
  path("shout-create/", views.shout_create_view, name="shout_create"),
68
+ path("shout/<str:shout_id>/delete/", views.shout_delete_view, name="shout_delete"),
40
69
  path("bbcode/", views.bbcode_view, name="bbcode"),
41
70
  ]