-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
180 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from django.core.management.base import BaseCommand | ||
from django.apps import apps | ||
|
||
class Command(BaseCommand): | ||
help = 'Delete all objects from all models in the simplemenu app' | ||
|
||
def handle(self, *args, **kwargs): | ||
# Get all models in the 'simplemenu' app | ||
app_models = apps.get_app_config('simplemenu').get_models() | ||
|
||
for model in app_models: | ||
# Delete all objects in the model | ||
model_name = model.__name__ | ||
try: | ||
deleted_count, _ = model.objects.all().delete() | ||
self.stdout.write(f'Successfully deleted {deleted_count} objects from {model_name}.') | ||
except Exception as e: | ||
self.stderr.write(f'Failed to delete objects from {model_name}: {str(e)}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
{% load i18n plugins_tagcloud simplemenu_tags static %} | ||
<nav id="sidebar" class="sidebar"> | ||
<ul class="content-wrapper"> | ||
<li> | ||
<a class="button is-success is-medium" href="{% url "plugin_upload" %}"> | ||
<i class="fas fa-upload"></i> | ||
{% trans "Upload a plugin" %} | ||
</a> | ||
</li> | ||
<hr/> | ||
{% get_namedmenu Navigation as menu %} | ||
{% for item in menu %} | ||
<li class="{% if request.path == item.page.url %}is-active{% endif %}"> | ||
<a href="{{ item.page.url }}"> | ||
{% if item.page.url == "/" %} | ||
<i class="fas fa-home mr-3"></i> | ||
{% elif item.page.url == "/plugins/" %} | ||
<i class="fas fa-plug mr-3"></i> | ||
{% elif item.page.url == "/plugins/my" %} | ||
<i class="fas fa-user mr-3"></i> | ||
{% endif %} | ||
{{ item.name }} | ||
</a> | ||
</li> | ||
{% endfor %} | ||
<li> | ||
<div class="has-child"> | ||
<a onclick="toggleSubMenu('news')"> | ||
<i class="fas fa-newspaper mr-3"></i> | ||
New & Updated | ||
</a> | ||
<span onclick="toggleSubMenu('news')" class="drop-arrow"><img src="{% static "images/arrow.svg" %}"/></span> | ||
</div> | ||
<ul class="collapsed" id="news"> | ||
{% get_namedmenu New as new %} | ||
{% for item in new %} | ||
<li class="has-child {% if request.path == item.page.url %}is-active{% endif %}"> | ||
<a href="{{ item.page.url }}"> | ||
{{ item.name }} | ||
</a> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</li> | ||
<li> | ||
<div class="has-child"> | ||
<a onclick="toggleSubMenu('top')"> | ||
<i class="fas fa-star mr-3"></i> | ||
Top | ||
</a> | ||
<span onclick="toggleSubMenu('top')" class="drop-arrow"><img src="{% static "images/arrow.svg" %}"/></span> | ||
</div> | ||
<ul class="collapsed" id="top"> | ||
{% get_namedmenu Top as Top %} | ||
{% for item in Top %} | ||
<li class="has-child {% if request.path == item.page.url %}is-active{% endif %}"> | ||
<a href="{{ item.page.url }}"> | ||
{{ item.name }} | ||
</a> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</li> | ||
<li> | ||
<div class="has-child"> | ||
<a onclick="toggleSubMenu('category')"> | ||
<i class="fas fa-list mr-3"></i> | ||
Category | ||
</a> | ||
<span onclick="toggleSubMenu('category')" class="drop-arrow"><img src="{% static "images/arrow.svg" %}"/></span> | ||
</div> | ||
<ul class="collapsed" id="category"> | ||
{% get_namedmenu Category as Category %} | ||
{% for item in Category %} | ||
<li class="has-child {% if request.path == item.page.url %}is-active{% endif %}"> | ||
<a href="{{ item.page.url }}"> | ||
{{ item.name }} | ||
</a> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</li> | ||
{% if user.is_authenticated and user.is_staff %} | ||
<li> | ||
<div class="has-child"> | ||
<a onclick="toggleSubMenu('unapproved')"> | ||
<i class="fas fa-check-circle mr-3"></i> | ||
Under review | ||
</a> | ||
<span onclick="toggleSubMenu('unapproved')" class="drop-arrow"><img src="{% static "images/arrow.svg" %}"/></span> | ||
</div> | ||
<ul class="collapsed" id="unapproved"> | ||
{% get_namedmenu Unapproved as Unapproved %} | ||
{% for item in Unapproved %} | ||
<li class="has-child {% if request.path == item.page.url %}is-active{% endif %}"> | ||
<a href="{{ item.page.url }}"> | ||
{{ item.name }} | ||
</a> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</li> | ||
{% endif %} | ||
|
||
<li> | ||
<div> | ||
<a href=""> | ||
{% include_plugins_tagcloud_modal 'plugins.plugin' %} | ||
</a> | ||
</div> | ||
</li> | ||
</ul> | ||
</nav> | ||
|
||
|
||
<script> | ||
function rotateArrow(e) { | ||
e.previousElementSibling.querySelector('img').classList.toggle('rotated'); | ||
} | ||
|
||
function toggleSubMenu(listId) { | ||
console.log(listId) | ||
let e = document.getElementById(listId); | ||
e.classList.toggle('unfolded'); | ||
rotateArrow(e); | ||
} | ||
|
||
function toggleMenu() { | ||
document.getElementById('sidebar').classList.toggle('visible'); | ||
document.getElementById('hamburger-btn').classList.toggle('open'); | ||
} | ||
|
||
// compose title for menu button: contatenate parent section titles | ||
{% comment %} let activeListItem = document.getElementsByClassName('is-active')[0]; | ||
let ham = document.getElementById('ham-title'); | ||
let hamTitle = activeListItem.querySelector('a').textContent; | ||
if (activeListItem.parentElement.previousElementSibling != null) { | ||
hamTitle = activeListItem.parentElement.previousElementSibling.querySelector('a').textContent + ' / ' + hamTitle; | ||
} | ||
ham.textContent = hamTitle; {% endcomment %} | ||
|
||
// expand active section | ||
document.querySelectorAll('li.is-active,li:has(.is-active)').forEach(li => { | ||
if (e = li.querySelector('ul')) { | ||
e.classList.toggle('unfolded'); | ||
} | ||
}); | ||
</script> |