12# added dropdown menu

This commit is contained in:
Eligiusz Kurzawa 2021-01-13 19:01:13 +01:00
parent e2706d640f
commit e09e0a5405
2 changed files with 51 additions and 7 deletions

View File

@ -4,7 +4,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<title>JobPortal - Free Bootstrap 4 Template by Colorlib</title> <title>JobPortal</title>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
@ -28,6 +28,8 @@
<link rel="stylesheet" href="{% static "css/flaticon.css" %}"> <link rel="stylesheet" href="{% static "css/flaticon.css" %}">
<link rel="stylesheet" href="{% static "css/icomoon.css" %}"> <link rel="stylesheet" href="{% static "css/icomoon.css" %}">
<link rel="stylesheet" href="{% static "css/style.css" %}"> <link rel="stylesheet" href="{% static "css/style.css" %}">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script>
</head> </head>
<body> <body>
@ -48,7 +50,37 @@
<li class="nav-item cta mr-md-2"><a href="{% url 'users:register' %}" class="nav-link">Register</a></li> <li class="nav-item cta mr-md-2"><a href="{% url 'users:register' %}" class="nav-link">Register</a></li>
<li class="nav-item cta cta-colored"><a href="{% url 'users:login' %}" class="nav-link">Login</a></li> <li class="nav-item cta cta-colored"><a href="{% url 'users:login' %}" class="nav-link">Login</a></li>
{% endif %} {% endif %}
{% if user.is_authenticated and user.is_employee %}
<div class="btn-group">
<button type="button" class="btn btn-success dropdown-toggle" style="height:50px" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{ user.first_name }}
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">My Jobs</a>
<a class="dropdown-item" href="">You Have {{ user.count_unread_messages }} message(s)</a>
<a class="dropdown-item" href="">My Wish List</a>
<a class="dropdown-item" href="{% url 'users:update_profile' pk=user.get_profile_id %}">Update Profile</a>
<a class="dropdown-item" href="">Change Password</a>
<a class="dropdown-item" href="{% url 'users:logout' %}">Logout</a>
</div>
</div>
{% endif %}
{% if user.is_authenticated and user.is_employer %}
<div class="btn-group">
<button type="button" class="btn btn-success dropdown-toggle" style="height:50px" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{ user.first_name }}
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="">Add Job</a>
<a class="dropdown-item" href="">My Jobs</a>
{% if user.get_profile_id %}
<a class="dropdown-item" href="{% url 'users:update_profile' pk=user.get_profile_id %}">Update Profile</a>
{% endif %}
<a class="dropdown-item" href="">Change Password</a>
<a class="dropdown-item" href="{% url 'users:logout' %}">Logout</a>
</div>
</div>
{% endif %}
</ul> </ul>
</div> </div>
</div> </div>
@ -56,8 +88,10 @@
<!-- END nav --> <!-- END nav -->
{% block content %} {% block content %}
{% endblock %} {% endblock %}
<section class="ftco-section-parallax"> <section class="ftco-section-parallax">
<div class="parallax-img d-flex align-items-center"> <div class="parallax-img d-flex align-items-center">
<div class="container"> <div class="container">
@ -168,6 +202,13 @@
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBVWaKrjvy3MaE7SQ74_uJiULgl1JY0H2s&sensor=false"></script> <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBVWaKrjvy3MaE7SQ74_uJiULgl1JY0H2s&sensor=false"></script>
<script src="{% static "js/google-map.js" %}"></script> <script src="{% static "js/google-map.js" %}"></script>
<script src="{% static "js/main.js" %}"></script> <script src="{% static "js/main.js" %}"></script>
{% if user.is_authenticated and user.is_employee %}
<script src="{% static "js/addorremove.js" %}"></script>
{% else %}
<script src="{% static "js/addorremove2.js" %}"></script>
{% endif %}
</body> </body>
</html> </html>

View File

@ -50,6 +50,9 @@ class Account(AbstractBaseUser, PermissionsMixin):
verbose_name = _('user') verbose_name = _('user')
verbose_name_plural = _('users') verbose_name_plural = _('users')
def get_profile_id(self):
return self.profile.id
class Profile(models.Model): class Profile(models.Model):
user = models.OneToOneField(Account, on_delete=models.CASCADE, related_name="profile") user = models.OneToOneField(Account, on_delete=models.CASCADE, related_name="profile")