-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from jazzband/release/v2.0.0
Prepare release of django-simple-menu 2.0.0
- Loading branch information
Showing
63 changed files
with
1,000 additions
and
758 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[run] | ||
source = menu | ||
source = simple_menu | ||
branch = 1 | ||
|
||
[report] | ||
omit = *migrations*,.tox/*,setup.py,*settings.py | ||
omit = *migrations*,.tox/*,setup.py,*settings.py,menu/* |
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
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
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 @@ | ||
### Django ### | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# PyCharm | ||
.idea/ | ||
|
||
# Visual Studio Code | ||
.vscode/ |
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 |
---|---|---|
@@ -1,30 +1,61 @@ | ||
Example Project for django-simple-menu | ||
====================================== | ||
============================== | ||
django-simple-menu example app | ||
============================== | ||
|
||
This is a complete example project for django-simple-menu that can be quickly | ||
used to evaluate if django-simple-menu is right for you. | ||
Set up | ||
------ | ||
|
||
Setting up | ||
---------- | ||
1. Create a virtualenv, source it, and install dependencies:: | ||
|
||
python3 -m venv .venv | ||
source .venv/bin/activate | ||
pip install -r requirements.txt | ||
|
||
2. Initialize a database and create test users:: | ||
|
||
python3 manage.py makemigrations | ||
python3 manage.py migrate | ||
python3 manage.py createsuperuser --username admin | ||
python3 manage.py createsuperuser --username user | ||
|
||
3. Run server:: | ||
|
||
python3 manage.py runserver | ||
|
||
4. Go to Django administration (probably under http://127.0.0.1:8000/admin/) | ||
and remove superuser rights from the second user you've created. | ||
|
||
5. Look around the website, try logging in, have fun :) | ||
|
||
To setup the project you need to create a new virtualenv directory and install | ||
the dependencies listed in the requirements file:: | ||
Screenshots | ||
----------- | ||
.. figure:: ./screenshots/main_page.png | ||
|
||
virtualenv testenv | ||
source testenv/bin/activate | ||
pip install -r requirements.txt | ||
Index page of the example app | ||
|
||
Next setup the Django instance:: | ||
.. figure:: ./screenshots/subpage.png | ||
|
||
Page featuring a submenu | ||
|
||
.. figure:: ./screenshots/user_page.png | ||
|
||
Page only shown to the authenticated users | ||
|
||
.. figure:: ./screenshots/secret_page.png | ||
|
||
Page only shown to the superusers | ||
|
||
Learn more | ||
---------- | ||
|
||
./manage.py syncdb | ||
Full documentation, including installation and configuration instructions, is | ||
available at https://django-simple-menu.readthedocs.io/. | ||
|
||
And finally run the project:: | ||
``django-simple-menu`` is released under the *BSD 2-Clause "Simplified" License*. | ||
If you like it, please consider contributing! | ||
|
||
./manage.py runserver | ||
``django-simple-menu`` was originally created by | ||
Evan Borgstom <[email protected]> and was further developed by many | ||
contributors_. | ||
|
||
Once you access the project at http://127.0.0.1:8000 you will see a menu that | ||
will change depending on if you're logged in, logged in as a staff member or | ||
logged in as a superuser. To fully see the menu system in action you will need | ||
to login to the Django admin and create two new users (one just a staff member | ||
and the other a regular user, you already have a superuser from the syncdb | ||
call) and then login with all three of them to compare the resulting menus. | ||
.. _contributors: https://github.com/jazzband/django-simple-menu/graphs/contributors |
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,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class AccountsConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'accounts' |
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 |
---|---|---|
@@ -1,36 +1,49 @@ | ||
from django.core.urlresolvers import reverse | ||
from django.urls import reverse | ||
|
||
from simple_menu import Menu, MenuItem | ||
|
||
from menu import Menu, MenuItem | ||
|
||
def profile_title(request): | ||
""" | ||
Return a personalized title for our profile menu item | ||
"""Return a personalized title for our profile menu item | ||
""" | ||
# we don't need to check if the user is authenticated because our menu | ||
# item will have a check that does that for us | ||
name = request.user.get_full_name() or request.user | ||
|
||
return "%s's Profile" % name | ||
return f"{name}'s Profile" | ||
|
||
Menu.add_item("main", MenuItem("Accounts Index", | ||
reverse("accounts.views.index"))) | ||
|
||
submenu_items = [ | ||
MenuItem(f"Page {i}", | ||
reverse('accounts:subpage', kwargs={'i': i}), | ||
icon=f'{i}-circle') | ||
for i in range(1, 4) | ||
] | ||
Menu.add_item("user", MenuItem("Subpages", | ||
reverse('accounts:subpage', kwargs={'i': 1}), | ||
icon="menu-app", | ||
children=submenu_items)) | ||
|
||
# this item will be shown to users who are not logged in | ||
Menu.add_item("user", MenuItem("Login", | ||
reverse('django.contrib.auth.views.login'), | ||
check=lambda request: not request.user.is_authenticated())) | ||
Menu.add_item("user", MenuItem("Sign in", | ||
reverse('accounts:sign_in'), | ||
icon='box-arrow-in-right', | ||
check=lambda r: not r.user.is_authenticated)) | ||
|
||
# this will only be shown to logged in users and also demonstrates how to use | ||
# a callable for the title to return a customized title for each request | ||
Menu.add_item("user", MenuItem(profile_title, | ||
reverse('accounts.views.profile'), | ||
check=lambda request: request.user.is_authenticated())) | ||
Menu.add_item("user", MenuItem("Logout", | ||
reverse('django.contrib.auth.views.logout'), | ||
check=lambda request: request.user.is_authenticated())) | ||
reverse('accounts:profile'), | ||
icon='person-circle', | ||
check=lambda r: r.user.is_authenticated)) | ||
|
||
# this only shows to superusers | ||
Menu.add_item("user", MenuItem("Admin", | ||
reverse("admin:index"), | ||
separator=True, | ||
check=lambda request: request.user.is_superuser)) | ||
Menu.add_item("user", MenuItem("Secret superuser page", | ||
reverse("accounts:super_only"), | ||
icon='incognito', | ||
check=lambda r: r.user.is_superuser)) | ||
|
||
Menu.add_item("user", MenuItem("Sign out", | ||
reverse('accounts:sign_out'), | ||
icon='box-arrow-right', | ||
check=lambda r: r.user.is_authenticated)) |
File renamed without changes.
Oops, something went wrong.