punkweb-bb 0.1.4__py3-none-any.whl → 0.2.0__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 (43) 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__/tests.cpython-311.pyc +0 -0
  4. punkweb_bb/__pycache__/urls.cpython-311.pyc +0 -0
  5. punkweb_bb/__pycache__/utils.cpython-311.pyc +0 -0
  6. punkweb_bb/__pycache__/views.cpython-311.pyc +0 -0
  7. punkweb_bb/forms.py +40 -7
  8. punkweb_bb/models.py +21 -0
  9. punkweb_bb/static/punkweb_bb/css/category-form.css +24 -0
  10. punkweb_bb/static/punkweb_bb/css/index.css +6 -0
  11. punkweb_bb/static/punkweb_bb/css/punkweb.css +61 -5
  12. punkweb_bb/static/punkweb_bb/css/shoutbox.css +13 -2
  13. punkweb_bb/static/punkweb_bb/css/subcategory-form.css +24 -0
  14. punkweb_bb/static/punkweb_bb/css/subcategory.css +12 -0
  15. punkweb_bb/static/punkweb_bb/css/thread.css +19 -0
  16. punkweb_bb/static/punkweb_bb/css/variables.css +1 -0
  17. punkweb_bb/templates/punkweb_bb/category_create.html +50 -0
  18. punkweb_bb/templates/punkweb_bb/category_update.html +53 -0
  19. punkweb_bb/templates/punkweb_bb/index.html +27 -1
  20. punkweb_bb/templates/punkweb_bb/partials/category_delete.html +11 -0
  21. punkweb_bb/templates/punkweb_bb/partials/shout_delete.html +11 -0
  22. punkweb_bb/templates/punkweb_bb/partials/subcategory_delete.html +11 -0
  23. punkweb_bb/templates/punkweb_bb/shoutbox/shout_list.html +14 -4
  24. punkweb_bb/templates/punkweb_bb/subcategory.html +21 -6
  25. punkweb_bb/templates/punkweb_bb/subcategory_create.html +53 -0
  26. punkweb_bb/templates/punkweb_bb/subcategory_update.html +56 -0
  27. punkweb_bb/templates/punkweb_bb/thread.html +26 -6
  28. punkweb_bb/templates/punkweb_bb/thread_create.html +1 -0
  29. punkweb_bb/templatetags/__pycache__/can_delete.cpython-311.pyc +0 -0
  30. punkweb_bb/templatetags/__pycache__/can_edit.cpython-311.pyc +0 -0
  31. punkweb_bb/templatetags/__pycache__/can_post.cpython-311.pyc +0 -0
  32. punkweb_bb/templatetags/can_delete.py +8 -0
  33. punkweb_bb/templatetags/can_edit.py +8 -0
  34. punkweb_bb/templatetags/can_post.py +8 -0
  35. punkweb_bb/tests.py +5 -5
  36. punkweb_bb/urls.py +27 -0
  37. punkweb_bb/utils.py +17 -0
  38. punkweb_bb/views.py +232 -45
  39. {punkweb_bb-0.1.4.dist-info → punkweb_bb-0.2.0.dist-info}/METADATA +2 -2
  40. {punkweb_bb-0.1.4.dist-info → punkweb_bb-0.2.0.dist-info}/RECORD +43 -26
  41. {punkweb_bb-0.1.4.dist-info → punkweb_bb-0.2.0.dist-info}/LICENSE +0 -0
  42. {punkweb_bb-0.1.4.dist-info → punkweb_bb-0.2.0.dist-info}/WHEEL +0 -0
  43. {punkweb_bb-0.1.4.dist-info → punkweb_bb-0.2.0.dist-info}/top_level.txt +0 -0
Binary file
punkweb_bb/forms.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from django import forms
2
2
  from django.contrib.auth.forms import AuthenticationForm, UserCreationForm
3
3
 
4
- from punkweb_bb.models import BoardProfile, Post, Shout, Thread
4
+ from punkweb_bb.models import BoardProfile, Category, Post, Shout, Subcategory, Thread
5
5
  from punkweb_bb.widgets import BBCodeEditorWidget
6
6
 
7
7
 
@@ -43,6 +43,21 @@ class BoardProfileModelForm(forms.ModelForm):
43
43
  }
44
44
 
45
45
 
46
+ class CategoryModelForm(forms.ModelForm):
47
+ class Meta:
48
+ model = Category
49
+ fields = (
50
+ "name",
51
+ "order",
52
+ )
53
+ widgets = {
54
+ "name": forms.TextInput(attrs={"autofocus": True, "class": "pw-input"}),
55
+ "order": forms.TextInput(
56
+ attrs={"class": "pw-input", "min": "0", "type": "number"}
57
+ ),
58
+ }
59
+
60
+
46
61
  class PostModelForm(forms.ModelForm):
47
62
  class Meta:
48
63
  model = Post
@@ -55,6 +70,30 @@ class PostModelForm(forms.ModelForm):
55
70
  }
56
71
 
57
72
 
73
+ class ShoutModelForm(forms.ModelForm):
74
+ class Meta:
75
+ model = Shout
76
+ fields = ("content",)
77
+
78
+
79
+ class SubcategoryModelForm(forms.ModelForm):
80
+ class Meta:
81
+ model = Subcategory
82
+ fields = (
83
+ "name",
84
+ "description",
85
+ "order",
86
+ "staff_post_only",
87
+ )
88
+ widgets = {
89
+ "name": forms.TextInput(attrs={"autofocus": True, "class": "pw-input"}),
90
+ "description": BBCodeEditorWidget(),
91
+ "order": forms.TextInput(
92
+ attrs={"class": "pw-input", "min": "0", "type": "number"}
93
+ ),
94
+ }
95
+
96
+
58
97
  class ThreadModelForm(forms.ModelForm):
59
98
  class Meta:
60
99
  model = Thread
@@ -66,9 +105,3 @@ class ThreadModelForm(forms.ModelForm):
66
105
  "title": forms.TextInput(attrs={"autofocus": True, "class": "pw-input"}),
67
106
  "content": BBCodeEditorWidget(),
68
107
  }
69
-
70
-
71
- class ShoutModelForm(forms.ModelForm):
72
- class Meta:
73
- model = Shout
74
- fields = ("content",)
punkweb_bb/models.py CHANGED
@@ -79,6 +79,9 @@ class Subcategory(UUIDPrimaryKeyMixin, TimestampMixin):
79
79
  "order",
80
80
  )
81
81
 
82
+ def can_post(self, user):
83
+ return not self.staff_post_only or user.is_staff
84
+
82
85
  @property
83
86
  def thread_count(self):
84
87
  return self.threads.count()
@@ -120,6 +123,15 @@ class Thread(UUIDPrimaryKeyMixin, TimestampMixin):
120
123
  def __str__(self):
121
124
  return f"{self.title}"
122
125
 
126
+ def can_edit(self, user):
127
+ return user == self.user or user.has_perm("punkweb_bb.change_thread")
128
+
129
+ def can_delete(self, user):
130
+ return user == self.user or user.has_perm("punkweb_bb.delete_thread")
131
+
132
+ def can_post(self, user):
133
+ return not self.is_closed
134
+
123
135
  @property
124
136
  def post_count(self):
125
137
  return self.posts.count()
@@ -143,6 +155,12 @@ class Post(UUIDPrimaryKeyMixin, TimestampMixin):
143
155
  def __str__(self):
144
156
  return f"{self.thread} > {self.user} > {self.created_at}"
145
157
 
158
+ def can_edit(self, user):
159
+ return user == self.user or user.has_perm("punkweb_bb.change_post")
160
+
161
+ def can_delete(self, user):
162
+ return user == self.user or user.has_perm("punkweb_bb.delete_post")
163
+
146
164
  @property
147
165
  def index(self):
148
166
  # Returns the index of the post in the thread, starting with 1
@@ -180,3 +198,6 @@ class Shout(UUIDPrimaryKeyMixin, TimestampMixin):
180
198
 
181
199
  def __str__(self):
182
200
  return f"{self.user} > {self.created_at}"
201
+
202
+ def can_delete(self, user):
203
+ return user == self.user or user.has_perm("punkweb_bb.delete_shout")
@@ -0,0 +1,24 @@
1
+ .categoryForm {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 1rem;
5
+ }
6
+
7
+ .categoryForm__field {
8
+ align-items: start;
9
+ display: flex;
10
+ flex-direction: column;
11
+ gap: 0.5rem;
12
+ }
13
+
14
+ .categoryForm .errorlist {
15
+ color: var(--oc-red-9);
16
+ margin: 0;
17
+ }
18
+
19
+ .categoryForm__actions {
20
+ align-items: center;
21
+ display: flex;
22
+ justify-content: flex-end;
23
+ gap: 1rem;
24
+ }
@@ -7,6 +7,12 @@
7
7
  flex: 1;
8
8
  }
9
9
 
10
+ .index__category__actions {
11
+ align-items: center;
12
+ display: flex;
13
+ gap: 0.25rem;
14
+ }
15
+
10
16
  .index__sidebar {
11
17
  flex: 0 0 20rem;
12
18
  }
@@ -406,6 +406,67 @@ blockquote cite {
406
406
  width: 2rem;
407
407
  }
408
408
 
409
+ .pw-icon-button .material-symbols-outlined {
410
+ display: block;
411
+ font-size: 1.125rem;
412
+ }
413
+
414
+ .pw-icon-button.xs {
415
+ height: 1rem;
416
+ line-height: 1rem;
417
+ max-height: 1rem;
418
+ max-width: 1rem;
419
+ min-height: 1rem;
420
+ min-width: 1rem;
421
+ width: 1rem;
422
+ }
423
+
424
+ .pw-icon-button.xs .material-symbols-outlined {
425
+ font-size: 0.875rem;
426
+ }
427
+
428
+ .pw-icon-button.sm {
429
+ height: 1.5rem;
430
+ line-height: 1.5rem;
431
+ max-height: 1.5rem;
432
+ max-width: 1.5rem;
433
+ min-height: 1.5rem;
434
+ min-width: 1.5rem;
435
+ width: 1.5rem;
436
+ }
437
+
438
+ .pw-icon-button.sm .material-symbols-outlined {
439
+ font-size: 1rem;
440
+ }
441
+
442
+ .pw-icon-button.lg {
443
+ height: 2.5rem;
444
+ line-height: 2.5rem;
445
+ max-height: 2.5rem;
446
+ max-width: 2.5rem;
447
+ min-height: 2.5rem;
448
+ min-width: 2.5rem;
449
+ width: 2.5rem;
450
+ }
451
+
452
+ .pw-icon-button.lg .material-symbols-outlined {
453
+ font-size: 1.25rem;
454
+ }
455
+
456
+ .pw-icon-button.xl {
457
+ height: 3rem;
458
+ line-height: 3rem;
459
+ max-height: 3rem;
460
+ max-width: 3rem;
461
+ min-height: 3rem;
462
+ min-width: 3rem;
463
+ width: 3rem;
464
+ }
465
+
466
+ .pw-icon-button.sl .material-symbols-outlined {
467
+ font-size: 1.5rem;
468
+ }
469
+
409
470
  .pw-icon-button:disabled {
410
471
  background-color: var(--oc-gray-5) !important;
411
472
  border-color: var(--oc-gray-5) !important;
@@ -413,11 +474,6 @@ blockquote cite {
413
474
  cursor: not-allowed;
414
475
  }
415
476
 
416
- .pw-icon-button .material-symbols-outlined {
417
- display: block;
418
- font-size: 1.125rem;
419
- }
420
-
421
477
  .pw-icon-button.rounded {
422
478
  border-radius: 100%;
423
479
  }
@@ -3,16 +3,27 @@
3
3
  display: flex;
4
4
  flex-direction: column;
5
5
  height: 12rem;
6
- gap: 0.25rem;
7
6
  overflow-y: auto;
8
- padding: 1rem;
9
7
  }
10
8
 
11
9
  .shoutbox__shout {
10
+ align-items: center;
11
+ display: flex;
12
+ justify-content: space-between;
12
13
  font-size: 0.75rem;
14
+ padding: 0.25rem 1rem;
13
15
  white-space: wrap;
14
16
  }
15
17
 
18
+ .shoutbox__shout:hover {
19
+ background-color: var(--oc-gray-1);
20
+ }
21
+
22
+ .shoutbox__shout__actions {
23
+ align-items: center;
24
+ display: flex;
25
+ }
26
+
16
27
  .shoutbox__form {
17
28
  padding: 0.5rem 0;
18
29
  }
@@ -0,0 +1,24 @@
1
+ .subcategoryForm {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 1rem;
5
+ }
6
+
7
+ .subcategoryForm__field {
8
+ align-items: start;
9
+ display: flex;
10
+ flex-direction: column;
11
+ gap: 0.5rem;
12
+ }
13
+
14
+ .subcategoryForm .errorlist {
15
+ color: var(--oc-red-9);
16
+ margin: 0;
17
+ }
18
+
19
+ .subcategoryForm__actions {
20
+ align-items: center;
21
+ display: flex;
22
+ justify-content: flex-end;
23
+ gap: 1rem;
24
+ }
@@ -5,6 +5,18 @@
5
5
  margin: 2rem 0;
6
6
  }
7
7
 
8
+ .subcategory__header__name {
9
+ align-items: center;
10
+ display: flex;
11
+ gap: 1rem;
12
+ }
13
+
14
+ .subcategory__header__actions {
15
+ align-items: center;
16
+ display: flex;
17
+ gap: 0.5rem;
18
+ }
19
+
8
20
  .thread__title {
9
21
  align-items: center;
10
22
  display: flex;
@@ -55,6 +55,25 @@
55
55
  color: var(--body-fg);
56
56
  }
57
57
 
58
+ .thread__user__groups {
59
+ display: flex;
60
+ flex-direction: column;
61
+ gap: 0.5rem;
62
+ width: 100%;
63
+ }
64
+
65
+ .thread__user__group {
66
+ background-color: var(--primary-8);
67
+ border: 1px solid var(--primary-9);
68
+ border-radius: 0.25rem;
69
+ color: var(--text-on-primary);
70
+ display: flex;
71
+ font-size: 0.875rem;
72
+ justify-content: center;
73
+ padding: 0.5rem;
74
+ width: 100%;
75
+ }
76
+
58
77
  .thread__main {
59
78
  display: flex;
60
79
  flex-direction: column;
@@ -12,6 +12,7 @@
12
12
 
13
13
  --text-dark: var(--oc-gray-9);
14
14
  --text-light: var(--oc-gray-0);
15
+ --text-on-primary: var(--oc-gray-0);
15
16
 
16
17
  --body-bg: var(--oc-white);
17
18
  --body-fg: var(--text-dark);
@@ -0,0 +1,50 @@
1
+ {% extends 'punkweb_bb/base.html' %}
2
+ {% load static %}
3
+
4
+ {% block title_prefix %}Create Category | {% endblock %}
5
+
6
+ {% block extra_head %}
7
+ {{form.media.css}}
8
+ <link rel="stylesheet" href="{% static 'punkweb_bb/css/category-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 active">
19
+ Create Category
20
+ </li>
21
+ </ul>
22
+ </nav>
23
+
24
+ <div class="pw-card fluid">
25
+ <div class="pw-card-header">Create Category</div>
26
+ <div class="pw-card-content">
27
+ <form class="categoryForm" action="{% url 'punkweb_bb:category_create' %}" method="post">
28
+ {% csrf_token %}
29
+ {% for field in form %}
30
+ <div class="categoryForm__field">
31
+ <label class="pw-input-label" for="{{ field.id_for_label }}">{{ field.label }}</label>
32
+ {{ field }}
33
+ </div>
34
+ {% endfor %}
35
+ {% if form.non_field_errors %}
36
+ {{ form.non_field_errors }}
37
+ {% endif %}
38
+ <div class="categoryForm__actions">
39
+ <a class="pw-button default" href="{% url 'punkweb_bb:index' %}" type="submit">Cancel</a>
40
+ <button class="pw-button raised primary" type="submit">Create</button>
41
+ </div>
42
+ </form>
43
+ </div>
44
+ </div>
45
+
46
+ {% endblock %}
47
+
48
+ {% block extra_script %}
49
+ {{form.media.js}}
50
+ {% endblock %}
@@ -0,0 +1,53 @@
1
+ {% extends 'punkweb_bb/base.html' %}
2
+ {% load static %}
3
+
4
+ {% block title_prefix %}Edit Category | {% endblock %}
5
+
6
+ {% block extra_head %}
7
+ {{form.media.css}}
8
+ <link rel="stylesheet" href="{% static 'punkweb_bb/css/category-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
+ Edit
23
+ </li>
24
+ </ul>
25
+ </nav>
26
+
27
+ <div class="pw-card fluid">
28
+ <div class="pw-card-header">Edit Category</div>
29
+ <div class="pw-card-content">
30
+ <form class="categoryForm" action="{% url 'punkweb_bb:category_update' category.slug %}" method="post">
31
+ {% csrf_token %}
32
+ {% for field in form %}
33
+ <div class="categoryForm__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="categoryForm__actions">
42
+ <a class="pw-button default" href="{{category.get_absolute_url}}">Cancel</a>
43
+ <button class="pw-button raised primary" type="submit">Save</button>
44
+ </div>
45
+ </form>
46
+ </div>
47
+ </div>
48
+
49
+ {% endblock %}
50
+
51
+ {% block extra_script %}
52
+ {{form.media.js}}
53
+ {% endblock %}
@@ -38,12 +38,35 @@
38
38
  </tr>
39
39
  </thead>
40
40
  <tbody>
41
+ {% if perms.punkweb_bb.add_subcategory or perms.punkweb_bb.change_category or perms.punkweb_bb.delete_category %}
42
+ <tr>
43
+ <td colspan="4">
44
+ <div class="index__category__actions">
45
+ {% if perms.punkweb_bb.add_subcategory %}
46
+ <a class="pw-button ghost xs" href="{% url 'punkweb_bb:subcategory_create' category.slug %}">
47
+ Create Subcategory
48
+ </a>
49
+ {% endif %}
50
+ {% if perms.punkweb_bb.change_category %}
51
+ <a class="pw-button ghost xs" href="{% url 'punkweb_bb:category_update' category.slug %}">
52
+ Edit
53
+ </a>
54
+ {% endif %}
55
+ {% if perms.punkweb_bb.delete_category %}
56
+ <a class="pw-button ghost danger xs" hx-get="{% url 'punkweb_bb:category_delete' category.slug %}" hx-target="#modal-portal">
57
+ Delete
58
+ </a>
59
+ {% endif %}
60
+ </div>
61
+ </td>
62
+ </tr>
63
+ {% endif %}
41
64
  {% for subcategory in category.subcategories.all %}
42
65
  <tr>
43
66
  <td>
44
67
  <a href="{{subcategory.get_absolute_url}}" title="{{subcategory.name}}">{{subcategory.name}}</a>
45
68
  <div>
46
- {{subcategory.description}}
69
+ {{subcategory.description.rendered}}
47
70
  </div>
48
71
  </td>
49
72
  <td>{{subcategory.thread_count}}</td>
@@ -110,6 +133,9 @@
110
133
  </div>
111
134
  </div>
112
135
  {% endfor %}
136
+ {% if perms.punkweb_bb.add_category %}
137
+ <a class="pw-button ghost xs" href="{% url 'punkweb_bb:category_create' %}">Create Category</a>
138
+ {% endif %}
113
139
  </div>
114
140
  <div class="index__sidebar">
115
141
  <div class="pw-card fluid">
@@ -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 %}
@@ -1,9 +1,19 @@
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 class="pw-icon-button danger xs" hx-get="{% url 'punkweb_bb:shout_delete' shout.id %}"
13
+ hx-target="#modal-portal">
14
+ <span class="material-symbols-outlined">close</span>
15
+ </button>
16
+ </div>
17
+ {% endif %}
8
18
  </div>
9
19
  {% endfor %}
@@ -1,5 +1,5 @@
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
5
 
@@ -24,21 +24,36 @@
24
24
  </nav>
25
25
 
26
26
  <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 %}
27
+ <div class="subcategory__header__name">
28
+ <h1>{{subcategory.name}}</h1>
29
+ {% if perms.punkweb_bb.change_subcategory or perms.punkweb_bb.delete_subcategory %}
30
+ <div class="subcategory__header__actions">
31
+ {% if perms.punkweb_bb.change_subcategory %}
32
+ <a class="pw-button ghost xs" href="{% url 'punkweb_bb:subcategory_update' subcategory.slug %}">
33
+ Edit
34
+ </a>
35
+ {% endif %}
36
+ {% if perms.punkweb_bb.delete_subcategory %}
37
+ <a class="pw-button ghost danger xs" hx-get="{% url 'punkweb_bb:subcategory_delete' subcategory.slug %}" hx-target="#modal-portal">
38
+ Delete
39
+ </a>
40
+ {% endif %}
41
+ </div>
42
+ {% endif %}
43
+ </div>
44
+
45
+ {% if subcategory|can_post:request.user %}
30
46
  <a class="pw-button ghost primary" href="{% url 'punkweb_bb:thread_create' subcategory.slug %}">Create Thread</a>
31
47
  {% else %}
32
48
  <button
33
49
  class="pw-button ghost primary"
34
50
  disabled
35
51
  href="{% url 'punkweb_bb:thread_create' subcategory.slug %}"
36
- title="Only staff can create threads in this subcategory"
52
+ title="You do not have permission to create a thread in this subcategory."
37
53
  >
38
54
  Create Thread
39
55
  </button>
40
56
  {% endif %}
41
- {% endif %}
42
57
  </div>
43
58
 
44
59
  <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 %}