Skip to content

Commit

Permalink
💻 Super teacher can delete public tags (#5617)
Browse files Browse the repository at this point in the history
- teacher1 is now always a super teacher in the dev_database
- when a tag was deleted from an adventure, the popularity wasn't decreased
- when you would add a tag to an adventure without a name, it would throw a 500 because the adventure wouldn't exist without a name
- some cleaning up

**How to test**
Add some tags in (public) adventures and delete them as a Super Teacher
<img width="1438" alt="Screenshot 2024-06-17 at 14 38 03" src="https://github.com/hedyorg/hedy/assets/48122190/c13879c3-92cd-464f-9dc4-1073d912b516">
  • Loading branch information
Annelein committed Jun 19, 2024
1 parent 5ea8667 commit 06a369f
Show file tree
Hide file tree
Showing 67 changed files with 435 additions and 24 deletions.
6 changes: 6 additions & 0 deletions messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,9 @@ msgstr ""
msgid "delete_success"
msgstr ""

msgid "delete_tag_prompt"
msgstr ""

msgid "destroy_profile"
msgstr ""

Expand Down Expand Up @@ -1136,6 +1139,9 @@ msgstr ""
msgid "no_tag"
msgstr ""

msgid "not_adventure_yet"
msgstr ""

msgid "not_enrolled"
msgstr ""

Expand Down
4 changes: 2 additions & 2 deletions static/js/appbundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -104579,7 +104579,7 @@ def note_with_error(value, err):
}
modal.confirm(text, async () => {
try {
await postNoResponse(by_super_teacher ? "/super-teacher/markAsTeacher" : "/admin/markAsTeacher", {
await postNoResponse(by_super_teacher ? "/super-teacher/mark-as-teacher" : "/admin/mark-as-teacher", {
username,
is_teacher
});
Expand All @@ -104590,7 +104590,7 @@ def note_with_error(value, err):
}
}, async () => {
if (pending_request) {
await postJson("/admin/markAsTeacher", {
await postJson("/admin/mark-as-teacher", {
username,
is_teacher: false
});
Expand Down
4 changes: 2 additions & 2 deletions static/js/appbundle.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions static/js/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export function markAsTeacher(checkbox: any, username: string, is_teacher: boole
}
modal.confirm (text, async () => {
try {
await postNoResponse(by_super_teacher ? '/super-teacher/markAsTeacher' : '/admin/markAsTeacher', {
await postNoResponse(by_super_teacher ? '/super-teacher/mark-as-teacher' : '/admin/mark-as-teacher', {
username: username,
is_teacher: is_teacher,
});
Expand All @@ -204,7 +204,7 @@ export function markAsTeacher(checkbox: any, username: string, is_teacher: boole
}, async () => {
// If there is a pending request, we decline the modal -> remove the teacher request
if (pending_request) {
await postJson('/admin/markAsTeacher', {
await postJson('/admin/mark-as-teacher', {
username: username,
is_teacher: false
});
Expand Down
1 change: 1 addition & 0 deletions templates/super-teacher/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ <h1 class="text-center mb-10">Super teacher overview</h1>
<button class="green-btn p-4" id="users_button" onclick="window.open('/feedback', '_self')">Feedback overview</button>
<button class="green-btn p-4" onclick="window.open('/super-teacher/support', '_self')">Teacher support overview</button>
<button class="green-btn p-4" onclick="window.open('/public-adventures', '_self')">Public adventures overview</button>
<button class="green-btn p-4" onclick="window.open('/super-teacher/tags', '_self')">Tags overview</button>
</div>
{% endblock %}
36 changes: 36 additions & 0 deletions templates/super-teacher/tags.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{% extends "auth.html" %}

{% block regular_content %}
<h4 class="text-center">All public tags</h4>
<h6 class="text-center">June 2024: Popularity might not be accurate, because up until now, it wasn't decreased when a tag was deleted.<br><br></h6>
<div class="program w-full ">
<table class="w-full border border-gray-400">
<thead>
<tr class="bg-blue-300 text-blue-900">
<td class="px-2 py-2 text-center" id="name_header">Name</td>
<td class="px-2 py-2 text-center" id="popularity_header">Popularity</td>
<td class="px-2 py-2 text-white text-center bg-blue-900" id="">Delete</td>
</tr>
</thead>
<tbody>
{% for tag in tags %}
<tr class="{% if loop.index is divisibleby 2 %}bg-gray-200{% else %}bg-white{% endif %}">
<td class="name_cell text-center p-2">{{tag.name}}</td>
<td class="popularity_cell text-center p-2">{{tag.popularity}}</td>
<td class="delete_cell text-center cursor-pointer text-center p-2">
<i class="fa fa-trash p-2 bg-red-500 mr-4 rounded-full cursor-pointer" id=""
hx-confirm="{{_('delete_tag_prompt')}}"
hx-trigger="click"
hx-delete="/tags/delete/{{tag.name}}"
hx-swap="none"
_="on htmx:afterRequest if detail.xhr.status == 200 then window.location.reload()"></i>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if next_page_token %}
<button id="next_page_btn" data-page_token="{{next_page_token}}" class="green-btn mt-4">Next page »</button>
{% endif %}
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion tests_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def make_current_user_teacher(self):
Need to log in again to refresh the session.
"""
self.post_data('admin/markAsTeacher', {'username': self.username, 'is_teacher': True})
self.post_data('admin/mark-as-teacher', {'username': self.username, 'is_teacher': True})
return self.login_user(self.username)

def make_current_user_super_teacher(self):
Expand Down
6 changes: 6 additions & 0 deletions translations/ar/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,9 @@ msgstr "حذف الملف العام"
msgid "delete_success"
msgstr "تم حذف البرنامج بنجاح."

msgid "delete_tag_prompt"
msgstr ""

msgid "destroy_profile"
msgstr "حذف الملف الشخصي"

Expand Down Expand Up @@ -1343,6 +1346,9 @@ msgstr "لا يوجد هذا البرنامج في هيدي!"
msgid "no_tag"
msgstr "لم يتم تقديم أي علامة"

msgid "not_adventure_yet"
msgstr ""

msgid "not_enrolled"
msgstr "يبدو أنك لست في هذا الصف!"

Expand Down
6 changes: 6 additions & 0 deletions translations/bg/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,9 @@ msgstr "Delete public profile"
msgid "delete_success"
msgstr "Program deleted successfully."

msgid "delete_tag_prompt"
msgstr ""

msgid "destroy_profile"
msgstr "Изтриване на акаунта"

Expand Down Expand Up @@ -1487,6 +1490,9 @@ msgstr "Няма такава Хеди програма!"
msgid "no_tag"
msgstr "No tag provided!"

msgid "not_adventure_yet"
msgstr ""

msgid "not_enrolled"
msgstr "Изжлежда, че не си в този клас!"

Expand Down
6 changes: 6 additions & 0 deletions translations/bn/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,9 @@ msgstr "Delete public profile"
msgid "delete_success"
msgstr "Program deleted successfully."

msgid "delete_tag_prompt"
msgstr ""

#, fuzzy
msgid "destroy_profile"
msgstr "Delete profile"
Expand Down Expand Up @@ -1523,6 +1526,9 @@ msgstr "No such Hedy program!"
msgid "no_tag"
msgstr "No tag provided!"

msgid "not_adventure_yet"
msgstr ""

#, fuzzy
msgid "not_enrolled"
msgstr "Looks like you are not in this class!"
Expand Down
6 changes: 6 additions & 0 deletions translations/ca/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,9 @@ msgstr "Suprimeix el perfil públic"
msgid "delete_success"
msgstr "Programa suprimit amb èxit."

msgid "delete_tag_prompt"
msgstr ""

msgid "destroy_profile"
msgstr "Suprimeix el perfil"

Expand Down Expand Up @@ -1340,6 +1343,9 @@ msgstr "No such Hedy program!"
msgid "no_tag"
msgstr "No tag provided!"

msgid "not_adventure_yet"
msgstr ""

#, fuzzy
msgid "not_enrolled"
msgstr "Looks like you are not in this class!"
Expand Down
6 changes: 6 additions & 0 deletions translations/cs/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,9 @@ msgstr "Delete public profile"
msgid "delete_success"
msgstr "Program deleted successfully."

msgid "delete_tag_prompt"
msgstr ""

msgid "destroy_profile"
msgstr "Trvale odstranit účet"

Expand Down Expand Up @@ -1474,6 +1477,9 @@ msgstr "Neexistující program jazyka Hedy!"
msgid "no_tag"
msgstr "No tag provided!"

msgid "not_adventure_yet"
msgstr ""

msgid "not_enrolled"
msgstr "Zdá se, že do této třídy nepatříte!"

Expand Down
6 changes: 6 additions & 0 deletions translations/cy/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,9 @@ msgstr "Delete public profile"
msgid "delete_success"
msgstr "Program deleted successfully."

msgid "delete_tag_prompt"
msgstr ""

#, fuzzy
msgid "destroy_profile"
msgstr "Delete profile"
Expand Down Expand Up @@ -1536,6 +1539,9 @@ msgstr "No such Hedy program!"
msgid "no_tag"
msgstr "No tag provided!"

msgid "not_adventure_yet"
msgstr ""

#, fuzzy
msgid "not_enrolled"
msgstr "Looks like you are not in this class!"
Expand Down
6 changes: 6 additions & 0 deletions translations/da/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,9 @@ msgstr "Delete public profile"
msgid "delete_success"
msgstr "Program deleted successfully."

msgid "delete_tag_prompt"
msgstr ""

#, fuzzy
msgid "destroy_profile"
msgstr "Delete profile"
Expand Down Expand Up @@ -1536,6 +1539,9 @@ msgstr "No such Hedy program!"
msgid "no_tag"
msgstr "No tag provided!"

msgid "not_adventure_yet"
msgstr ""

#, fuzzy
msgid "not_enrolled"
msgstr "Looks like you are not in this class!"
Expand Down
6 changes: 6 additions & 0 deletions translations/de/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,9 @@ msgstr "Öffentliches Profil löschen"
msgid "delete_success"
msgstr "Programm erfolgreich gelöscht."

msgid "delete_tag_prompt"
msgstr ""

msgid "destroy_profile"
msgstr "Konto endgültig löschen"

Expand Down Expand Up @@ -1261,6 +1264,9 @@ msgstr "Dieses Hedy Programm gibt es nicht!"
msgid "no_tag"
msgstr "Kein Tag angegeben!"

msgid "not_adventure_yet"
msgstr ""

msgid "not_enrolled"
msgstr "Du bist anscheinend nicht für diesen Unterricht angemeldet!"

Expand Down
6 changes: 6 additions & 0 deletions translations/el/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,9 @@ msgstr "Διαγραφή δημόσιου προφίλ"
msgid "delete_success"
msgstr "Το πρόγραμμα διαγράφηκε με επιτυχία"

msgid "delete_tag_prompt"
msgstr ""

msgid "destroy_profile"
msgstr "Μόνιμη διαγραφή λογαριασμού"

Expand Down Expand Up @@ -1383,6 +1386,9 @@ msgstr "Δεν υπάρχει τέτοιο πρόγραμμα Hedy!"
msgid "no_tag"
msgstr "No tag provided!"

msgid "not_adventure_yet"
msgstr ""

msgid "not_enrolled"
msgstr "Φαίνεται πως δεν είστε σ' αυτήν την τάξη!"

Expand Down
6 changes: 6 additions & 0 deletions translations/en/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,9 @@ msgstr "Delete public profile"
msgid "delete_success"
msgstr "Program deleted successfully."

msgid "delete_tag_prompt"
msgstr "Are you sure you want to delete this tag?"

msgid "destroy_profile"
msgstr "Delete profile"

Expand Down Expand Up @@ -1165,6 +1168,9 @@ msgstr "No such Hedy program!"
msgid "no_tag"
msgstr "No tag provided!"

msgid "not_adventure_yet"
msgstr "You must fill in an adventure name first"

msgid "not_enrolled"
msgstr "Looks like you are not in this class!"

Expand Down
6 changes: 6 additions & 0 deletions translations/enm/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,9 @@ msgstr "Delete public profile"
msgid "delete_success"
msgstr "Program deleted successfully."

msgid "delete_tag_prompt"
msgstr ""

#, fuzzy
msgid "destroy_profile"
msgstr "Delete profile"
Expand Down Expand Up @@ -1539,6 +1542,9 @@ msgstr "No such Hedy program!"
msgid "no_tag"
msgstr "No tag provided!"

msgid "not_adventure_yet"
msgstr ""

#, fuzzy
msgid "not_enrolled"
msgstr "Looks like you are not in this class!"
Expand Down
6 changes: 6 additions & 0 deletions translations/eo/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,9 @@ msgstr "Forviŝi publikan profilon"
msgid "delete_success"
msgstr "Program deleted successfully."

msgid "delete_tag_prompt"
msgstr ""

msgid "destroy_profile"
msgstr "Forviŝi profilon"

Expand Down Expand Up @@ -1387,6 +1390,9 @@ msgstr "Programo ne ekzistas!"
msgid "no_tag"
msgstr "No tag provided!"

msgid "not_adventure_yet"
msgstr ""

msgid "not_enrolled"
msgstr "Ŝajne vi ne apartenas al ĉi tiu klaso!"

Expand Down
6 changes: 6 additions & 0 deletions translations/es/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,9 @@ msgstr "Eliminar perfil público"
msgid "delete_success"
msgstr "Programa eliminado correctamente."

msgid "delete_tag_prompt"
msgstr ""

msgid "destroy_profile"
msgstr "Borrar mi cuenta permanentemente"

Expand Down Expand Up @@ -1208,6 +1211,9 @@ msgstr "¡No se encontró el programa de Hedy!"
msgid "no_tag"
msgstr "¡Sin etiqueta!"

msgid "not_adventure_yet"
msgstr ""

msgid "not_enrolled"
msgstr "¡Parece que no perteneces a esta clase!"

Expand Down
6 changes: 6 additions & 0 deletions translations/et/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,9 @@ msgstr "Delete public profile"
msgid "delete_success"
msgstr "Program deleted successfully."

msgid "delete_tag_prompt"
msgstr ""

#, fuzzy
msgid "destroy_profile"
msgstr "Delete profile"
Expand Down Expand Up @@ -1505,6 +1508,9 @@ msgstr "Sellist programmi ei ole!"
msgid "no_tag"
msgstr "No tag provided!"

msgid "not_adventure_yet"
msgstr ""

msgid "not_enrolled"
msgstr "Sa ei ole selles klassis!"

Expand Down

0 comments on commit 06a369f

Please sign in to comment.