tab for selected users

This commit is contained in:
Alicja Cięciwa
2020-11-11 15:28:00 +01:00
parent 212b0008af
commit 37906ae85b
16 changed files with 64 additions and 43 deletions

19
.idea/workspace.xml generated
View File

@@ -2,22 +2,15 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="15f590a5-5017-44f1-a85e-17dfe3fc5379" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/templates/inputhours.html" afterDir="false" />
<change afterPath="$PROJECT_DIR$/work/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/work/admin.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/work/apps.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/work/forms.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/work/migrations/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/work/models.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/work/tests.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/work/views.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/templatetags/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/templatetags/auth_extras.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/work/templatetags/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/work/templatetags/auth_extras.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/urls.py" beforeDir="false" afterPath="$PROJECT_DIR$/config/urls.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/settings.py" beforeDir="false" afterPath="$PROJECT_DIR$/config/settings.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/db.sqlite3" beforeDir="false" afterPath="$PROJECT_DIR$/db.sqlite3" afterDir="false" />
<change beforePath="$PROJECT_DIR$/static/css/main.css" beforeDir="false" afterPath="$PROJECT_DIR$/static/css/main.css" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/base.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/base.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/home.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/home.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/registration/login.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/registration/login.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/work/migrations/__init__.py" beforeDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -65,6 +65,9 @@ TEMPLATES = [
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
'libraries': {
'auth_extras': 'templatetags.auth_extras',
}
},
},
]

Binary file not shown.

View File

@@ -15,7 +15,7 @@
{% endif %}
</head>
<body class="text-center">
<div class="navbar-wrapper">
<div class="navbar-wrapper">
<header>
<nav class="navbar fixed-top navbar-light bg-nav navbar-expand-md">
<!--Logo-->
@@ -32,24 +32,40 @@
<li class="nav-item">
<a class="nav-link" href="#">Start</a>
</li>
<!--Start-->
<!--Dodaj godziny-->
<li class="nav-item">
<a class="nav-link" href="#">Dodaj godziny</a>
</li>
{% load auth_extras %}
{% if request.user|has_group:"moderators" %}
<!--Dodaj pracownika-->
<li class="nav-item">
<a class="nav-link" href="#">Dodaj pracownika</a>
</li>
{% endif %}
</ul>
</div>
</nav>
</header>
</div>
</div>
<div class = "container">
<div class="row">
{% block content %}
{% endblock %}
</div>
<div class="row">
<footer><p class="mt-5 mb-3 text-muted">
&copy; Alicja Cięciwa</p></footer>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
</div>
</body>
</html>

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,9 @@
from django import template
from django.contrib.auth.models import Group
register = template.Library()
@register.filter(name='has_group')
def has_group(user, group_name):
group = Group.objects.get(name=group_name)
return True if group in user.groups.all() else False