diff options
author | Matthew Lemon <y@yulqen.org> | 2024-10-15 14:28:30 +0100 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-10-15 14:28:30 +0100 |
commit | a47f71efc9a7643be548f7f805e162a1942d3db4 (patch) | |
tree | 97dfb055c67ec582765658c9ccfa3ca3012caf06 | |
parent | 9015934a186b8843cc6d5ec48e41c5e2408f3fcf (diff) |
More CSS improvements and wip on profile page
- uses dividers between divs which I'm not sure I like
- etc
-rw-r--r-- | core/static/css/main.css | 6 | ||||
-rw-r--r-- | core/static/css/output.css | 45 | ||||
-rw-r--r-- | core/templates/core/base.html | 2 | ||||
-rw-r--r-- | core/templates/core/profile.html | 19 | ||||
-rw-r--r-- | core/views.py | 4 | ||||
-rw-r--r-- | engagements/models.py | 7 | ||||
-rw-r--r-- | myuser/models.py | 6 |
7 files changed, 75 insertions, 14 deletions
diff --git a/core/static/css/main.css b/core/static/css/main.css index 5be59b4..b5c61c9 100644 --- a/core/static/css/main.css +++ b/core/static/css/main.css @@ -1,3 +1,3 @@ -@import 'tailwindcss/base'; -@import 'tailwindcss/components'; -@import 'tailwindcss/utilities';
\ No newline at end of file +@tailwind base; +@tailwind components; +@tailwind utilities; diff --git a/core/static/css/output.css b/core/static/css/output.css index 4382d7f..3a5b9a1 100644 --- a/core/static/css/output.css +++ b/core/static/css/output.css @@ -612,6 +612,10 @@ video { z-index: 10; } +.m-2 { + margin: 0.5rem; +} + .mx-auto { margin-left: auto; margin-right: auto; @@ -849,11 +853,40 @@ video { border-bottom-width: calc(1px * var(--tw-divide-y-reverse)); } +.divide-y-2 > :not([hidden]) ~ :not([hidden]) { + --tw-divide-y-reverse: 0; + border-top-width: calc(2px * calc(1 - var(--tw-divide-y-reverse))); + border-bottom-width: calc(2px * var(--tw-divide-y-reverse)); +} + +.divide-y-4 > :not([hidden]) ~ :not([hidden]) { + --tw-divide-y-reverse: 0; + border-top-width: calc(4px * calc(1 - var(--tw-divide-y-reverse))); + border-bottom-width: calc(4px * var(--tw-divide-y-reverse)); +} + +.divide-solid > :not([hidden]) ~ :not([hidden]) { + border-style: solid; +} + +.divide-dashed > :not([hidden]) ~ :not([hidden]) { + border-style: dashed; +} + +.divide-double > :not([hidden]) ~ :not([hidden]) { + border-style: double; +} + .divide-gray-200 > :not([hidden]) ~ :not([hidden]) { --tw-divide-opacity: 1; border-color: rgb(229 231 235 / var(--tw-divide-opacity)); } +.divide-gray-300 > :not([hidden]) ~ :not([hidden]) { + --tw-divide-opacity: 1; + border-color: rgb(209 213 219 / var(--tw-divide-opacity)); +} + .overflow-hidden { overflow: hidden; } @@ -894,6 +927,11 @@ video { border-width: 2px; } +.border-y-0 { + border-top-width: 0px; + border-bottom-width: 0px; +} + .border-b { border-bottom-width: 1px; } @@ -1293,6 +1331,11 @@ video { color: rgb(161 161 170 / var(--tw-text-opacity)); } +.text-purple { + --tw-text-opacity: 1; + color: rgb(63 60 187 / var(--tw-text-opacity)); +} + .underline { text-decoration-line: underline; } @@ -1545,4 +1588,4 @@ video { padding-left: 2rem; padding-right: 2rem; } -}
\ No newline at end of file +} diff --git a/core/templates/core/base.html b/core/templates/core/base.html index e69eaeb..4c31294 100644 --- a/core/templates/core/base.html +++ b/core/templates/core/base.html @@ -29,7 +29,7 @@ </div> <div class="flex items-center space-x-4"> {% if request.user.is_authenticated %} - <span class="text-white">{{ user }}</span> + <a href="{% url 'profile' %}"><span class="text-white">{{ user }}</span></a> <a href="{% url 'logout' %}" class="text-white hover:text-blue-200">Log Out</a> {% else %} <a href="{% url 'login' %}" class="text-white hover:text-blue-200">Log In</a> diff --git a/core/templates/core/profile.html b/core/templates/core/profile.html index 66184f6..7f512e4 100644 --- a/core/templates/core/profile.html +++ b/core/templates/core/profile.html @@ -5,16 +5,16 @@ {% block content %} <div class="container my-4 bg-white"> - <div class="py-3 rounded border border-2"> + <div class="py-3 rounded border border-2 divide-y-2 divide-gray-300 divide-solid"> <div class="p-4"> <h1 class="font-bold text-lg">{{ user.first_name }} {{ user.last_name }} <span class="text-zinc-400 text-md font-normal"> ⚬ {{ user.designation }} {{ user.team.name }} </span></h1> + <a href="mailto:{{ user.email }}" class="text-blue-500 hover:underline">{{ user.email }}</a> </div> <div> - <p class="pl-4 pb-2">{{ user.dapsy }}</p> + <p class="pl-4 pb-2 my-4 text-purple">Is DAP-Sy: {{ user.dapsy }}</p> </div> - <hr> <div class="py-2 px-4"> - <p>Lead inspector for :</p> + <p class="font-semibold">Lead inspector for:</p> <ul class="list-disc px-2 mt-4"> {% for org in user.lead_for.all%} <li class="ml-4"> @@ -23,6 +23,17 @@ {% endfor %} </ul> </div> + <div class="py-2 px-4"> + <p class="font-semibold">Recent and upcoming engagements:</p> + <ul class="list-disc px-2 mt-4"> + {% for eng in user.get_all_engagements.all|dictsortreversed:"proposed_start_date" %} + <li class="ml-4"> + {{ eng.proposed_start_date|date:'d M y' }} - <a href="{% url 'engagements:engagement_detail' eng.id %}" class="text-blue-600 hover:underline">{{ eng.alt_str }}</a> + </li> + {% endfor %} + </ul> + </div> + </div> </div> diff --git a/core/views.py b/core/views.py index 4e7cd41..60f8837 100644 --- a/core/views.py +++ b/core/views.py @@ -20,5 +20,5 @@ def dashboard(request): @login_required def profile(request): - args = {"user": request.user} - return render(request, "core/profile.html", args) + context = {"user": request.user} + return render(request, "core/profile.html", context) diff --git a/engagements/models.py b/engagements/models.py index bb1d2bd..7aa361e 100644 --- a/engagements/models.py +++ b/engagements/models.py @@ -5,8 +5,6 @@ from django.db import models from django.db.models import Q from django.utils.text import slugify -from myuser.models import TeamUser - ES_YEAR_LENGTH = 3 @@ -145,7 +143,7 @@ class Engagement(Common): proposed_end_date = models.DateField(null=True, blank=True) engagement_type = models.ForeignKey(EngagementType, on_delete=models.CASCADE) external_party = models.ForeignKey(Organisation, on_delete=models.CASCADE) - officers = models.ManyToManyField(TeamUser) + officers = models.ManyToManyField("myuser.TeamUser") objects = EngagementManager() @@ -189,6 +187,9 @@ class Engagement(Common): dscs.add(si) return dscs + def alt_str(self): + return f"{self.engagement_type.name} at {self.external_party}" + def __str__(self): return f"{self.engagement_type.name} at {self.external_party} ({self.proposed_start_date})" diff --git a/myuser/models.py b/myuser/models.py index d9f8aba..d0f70ec 100644 --- a/myuser/models.py +++ b/myuser/models.py @@ -3,6 +3,8 @@ from django.contrib.auth.models import PermissionsMixin from django.db import models from django.db.models import BooleanField, CharField, EmailField +from engagements.models import Engagement + class Common(models.Model): date_created = models.DateTimeField(auto_now_add=True) @@ -60,6 +62,7 @@ class TeamUser(AbstractBaseUser, PermissionsMixin): The `has_perm` and `has_module_perms` methods are placeholders that always return `True`, indicating that the user has all permissions. The `is_staff` property is also a placeholder that returns the value of `is_admin`. """ + email = EmailField(verbose_name="email address", max_length=255, unique=True) first_name = CharField(max_length=20, null=True, blank=True) last_name = CharField(max_length=20, null=True, blank=True) @@ -78,6 +81,9 @@ class TeamUser(AbstractBaseUser, PermissionsMixin): def __str__(self): return self.email + def get_all_engagements(self): + return Engagement.objects.filter(officers__id__contains=self.id) + def fullname(self): return f"{self.first_name} {self.last_name}" |