-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add index page and final touches to navigation urls handling
Signed-off-by: Nir Izraeli <nirizr@gmail.com>
- Loading branch information
Showing
5 changed files
with
44 additions
and
11 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block title %} | ||
Collaboration - Projects | ||
{% endblock %} | ||
|
||
{% block content %} | ||
Projects!!1 | ||
{% endblock %} |
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,32 +1,45 @@ | ||
class Menu: | ||
active_url = None | ||
|
||
def __init__(self, name, url=None, icon=None, *submenu, **kwargs): | ||
def __init__(self, name, url=None, icon=None, *submenu): | ||
if self.active_url is None: | ||
raise RuntimeError("Active url is not set when menu item is created") | ||
|
||
self.name = name | ||
self.icon = icon if icon else '' | ||
self.url = url if url else '' | ||
self.url = url | ||
self.submenu = submenu | ||
self.active = (url == self.active_url or | ||
any(sm.active for sm in self.submenu)) | ||
print(self.name, self.url) | ||
|
||
@classmethod | ||
def set_url(cls, url): | ||
cls.active_url = '' if url is None else url | ||
|
||
@property | ||
def menu_class(self): | ||
return 'sub-menu' if self.submenu else 'mf' | ||
|
||
|
||
def navigation(request): | ||
Menu.active_url = request.resolver_match.url_name | ||
print(Menu.active_url) | ||
menu = [Menu("Dashboard", icon='fa-dashboard'), | ||
Menu.set_url(request.resolver_match.url_name) | ||
|
||
menu = [Menu("Dashboard", 'index', icon='fa-dashboard'), | ||
|
||
Menu("Collaboration", None, 'fa-cogs', | ||
Menu("Projects", url='project-list'), | ||
Menu("Files", url='file-list'), | ||
Menu("Tasks", url='task-list'), | ||
Menu("Instances", url='instance-list')), | ||
Menu("Instances", url='instance-list'))] | ||
|
||
Menu("Account", None, 'fa-desktop', | ||
Menu("Your profile", url='profile'), | ||
# Menu("Settings", url='settings'), | ||
Menu("Logout", url='auth_logout'))] | ||
if request.user.is_authenticated(): | ||
account = Menu("Account", None, 'fa-desktop', | ||
Menu("Your profile", url='profile'), | ||
# Menu("Settings", url='settings'), | ||
Menu("Logout", url='auth_logout')) | ||
else: | ||
account = Menu("Login", 'auth_login') | ||
menu.append(account) | ||
|
||
return {'navigation': 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block title %} | ||
Index | ||
{% endblock %} | ||
|
||
{% block content %} | ||
This is the index page! | ||
{% endblock %} |
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