From 391fe5c42aab5d9edf6540e80df7c93f1c917b5c Mon Sep 17 00:00:00 2001 From: Nathan Chapman Date: Wed, 28 Jul 2021 18:10:07 -0600 Subject: [PATCH] Add basic event system --- accounts/templates/accounts/profile.html | 12 ++++++---- board/templates/board/employee_detail.html | 8 ++++--- board/templates/board/employee_list.html | 3 ++- board/templates/board/event_create_form.html | 2 +- board/templates/board/event_form.html | 2 +- board/templates/board/event_list.html | 17 +++++++++++++ .../board/logentry_confirm_delete.html | 4 ++-- board/templates/board/logentry_form.html | 19 +++++++++++---- board/views.py | 12 ++++++++-- onboard/settings.py | 24 +++++++++---------- static/styles/main.css | 22 ++++++++++++++--- templates/base.html | 5 +--- 12 files changed, 91 insertions(+), 39 deletions(-) diff --git a/accounts/templates/accounts/profile.html b/accounts/templates/accounts/profile.html index acf3d50..9a54ced 100644 --- a/accounts/templates/accounts/profile.html +++ b/accounts/templates/accounts/profile.html @@ -25,7 +25,7 @@

Add event

-

Upcoming

+

Upcoming (next seven days)

{% for event in upcoming_events %}
@@ -49,9 +49,13 @@
{{date.grouper|date:"D, M j"}}
{% for entry in date.list %}

- {{entry.notes}} - for - {{entry.employee}} + {{entry.created_at|time:"TIME_FORMAT"}} + + {{entry.notes}} + for + {{entry.employee}} + + Edit

{% endfor %} {% endfor %} diff --git a/board/templates/board/employee_detail.html b/board/templates/board/employee_detail.html index f5eb452..4f57e28 100644 --- a/board/templates/board/employee_detail.html +++ b/board/templates/board/employee_detail.html @@ -60,9 +60,11 @@ {% for date in activity %}
{{date.grouper|date:"D, M j"}}
{% for entry in date.list %} -

- {{entry.created_at|time:"H:i"}} - {{entry.notes}}

+

+ {{entry.created_at|time:"TIME_FORMAT"}} + {{entry.notes}} + Edit +

{% endfor %} {% endfor %}
diff --git a/board/templates/board/employee_list.html b/board/templates/board/employee_list.html index ac68ece..13f37a0 100644 --- a/board/templates/board/employee_list.html +++ b/board/templates/board/employee_list.html @@ -8,7 +8,8 @@ {% for employee in employee_list %}

{{employee.full_name}}
- Hire date: {{employee.hire_date|date:"SHORT_DATE_FORMAT"}} + Hire date: {{employee.hire_date|date:"SHORT_DATE_FORMAT"}}
+ Department: {{employee.department}}

{% endfor %} diff --git a/board/templates/board/event_create_form.html b/board/templates/board/event_create_form.html index 698740d..aaa0dfc 100644 --- a/board/templates/board/event_create_form.html +++ b/board/templates/board/event_create_form.html @@ -8,7 +8,7 @@ {% csrf_token %} {{form.as_p}}

- or cancel + or cancel

diff --git a/board/templates/board/event_form.html b/board/templates/board/event_form.html index 5ca737b..4cd0c9c 100644 --- a/board/templates/board/event_form.html +++ b/board/templates/board/event_form.html @@ -8,7 +8,7 @@ {% csrf_token %} {{form.as_p}}

- or cancel + or cancel

diff --git a/board/templates/board/event_list.html b/board/templates/board/event_list.html index 5e8efb0..50110fc 100644 --- a/board/templates/board/event_list.html +++ b/board/templates/board/event_list.html @@ -20,5 +20,22 @@

There are no events yet.

{% endfor %} +
+ + {% if page_obj.has_previous %} + « first + previous + {% endif %} + + + Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}. + + + {% if page_obj.has_next %} + next + last » + {% endif %} + +
{% endblock %} diff --git a/board/templates/board/logentry_confirm_delete.html b/board/templates/board/logentry_confirm_delete.html index 7aae8ca..8eb1b92 100644 --- a/board/templates/board/logentry_confirm_delete.html +++ b/board/templates/board/logentry_confirm_delete.html @@ -3,10 +3,10 @@ {% block content %}

Delete {{logentry}}

-
+ {% csrf_token %}

- or cancel + or cancel

diff --git a/board/templates/board/logentry_form.html b/board/templates/board/logentry_form.html index b35e99a..0708d6a 100644 --- a/board/templates/board/logentry_form.html +++ b/board/templates/board/logentry_form.html @@ -2,9 +2,18 @@ {% block content %}
-

-
- -
-
+
+

Update Event

+

Delete this entry

+
+
+
+ {% csrf_token %} + {{form.as_p}} +

+ or cancel +

+
+
+ {% endblock %} \ No newline at end of file diff --git a/board/views.py b/board/views.py index 0cbd418..dc4ccce 100644 --- a/board/views.py +++ b/board/views.py @@ -118,7 +118,14 @@ class LogEntryUpdateView(LoginRequiredMixin, UpdateView): class LogEntryDeleteView(LoginRequiredMixin, DeleteView): model = LogEntry pk_url_kwarg = 'entry_pk' - success_url = reverse_lazy('entry-list') + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context['employee'] = Employee.objects.get(pk=self.kwargs['pk']) + return context + + def get_success_url(self): + return reverse('employee-detail', kwargs={'pk': self.kwargs['pk']}) # Todos @@ -177,6 +184,8 @@ class TodoDeleteDoneView(LoginRequiredMixin, TemplateView): # Events class EventListView(LoginRequiredMixin, ListView): model = Event + paginate_by = 100 + ordering = ('-date', '-time') class EventCreateView(LoginRequiredMixin, CreateView): model = Event @@ -194,4 +203,3 @@ class EventUpdateView(LoginRequiredMixin, UpdateView): class EventDeleteView(LoginRequiredMixin, DeleteView): model = Event success_url = reverse_lazy('profile-detail') - diff --git a/onboard/settings.py b/onboard/settings.py index 086bd93..a0775c0 100644 --- a/onboard/settings.py +++ b/onboard/settings.py @@ -25,7 +25,7 @@ with open('/etc/secret_key.txt') as f: SECRET_KEY = f.read().strip() # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = os.environ.get('DJANGO_DEBUG', '') != 'False' +DEBUG = False ALLOWED_HOSTS = ['onboard.windmillapps.org', '127.0.0.1'] @@ -53,7 +53,6 @@ MIDDLEWARE = [ 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'onboard.middleware.TimezoneMiddleware', ] ROOT_URLCONF = 'onboard.urls' @@ -127,10 +126,11 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.2/howto/static-files/ - +STATICFILES_DIRS = [ + BASE_DIR / 'static' + ] STATIC_URL = '/static/' -STATIC_ROOT = [BASE_DIR / 'static/'] -STATICFILES_DIRS = [BASE_DIR / 'static'] +STATIC_ROOT = '/var/www/onboard.windmillapps.org/static/' # Default primary key field type @@ -163,7 +163,7 @@ LOGGING = { # Email ANYMAIL = { - "MAILGUN_API_KEY": os.environ.get('MAILGUN_API_KEY'), + "MAILGUN_API_KEY": "key-b65d1f9e486825a7d01d099fd3062c2b", } SERVER_EMAIL = 'noreply@onboard.windmillapps.org' @@ -174,10 +174,8 @@ ADMINS = ( ) MANAGERS = ADMINS -EMAIL_BACKEND = os.environ.get('EMAIL_BACKEND') - - -SECURE_HSTS_SECONDS = os.environ.get('DJANGO_SECURE_HSTS_SECONDS', '') != 'False' -SECURE_SSL_REDIRECT = os.environ.get('DJANGO_SECURE_SSL_REDIRECT', '') != 'False' -SESSION_COOKIE_SECURE = os.environ.get('DJANGO_SESSION_COOKIE_SECURE', '') != 'False' -CSRF_COOKIE_SECURE = os.environ.get('DJANGO_CSRF_COOKIE_SECURE', '') != 'False' \ No newline at end of file +EMAIL_BACKEND = 'anymail.backends.mailgun.EmailBackend' +SECURE_HSTS_SECONDS = True +SECURE_SSL_REDIRECT = True +SESSION_COOKIE_SECURE = True +CSRF_COOKIE_SECURE = True diff --git a/static/styles/main.css b/static/styles/main.css index a82652e..0e037c5 100644 --- a/static/styles/main.css +++ b/static/styles/main.css @@ -1,8 +1,9 @@ :root { - --white: #fdfdff; + --white: #f8f8fb; --black: #393d3f; --grey: #a7b4bb; --blue: #10638c; + --red: #8c1016; } html { @@ -98,9 +99,11 @@ article { font-weight: 900; } -.navbar__menu { - +.navbar__mobile .menu__items { + text-align: center; } + + .navbar__menu_title { font-weight: 900; padding: 0.2rem 1rem; @@ -200,6 +203,10 @@ article { text-decoration: none; } +.action-button--danger { + background-color: var(--red); +} + /* FORMS */ input[type=text]:not([name=description]), @@ -326,4 +333,13 @@ hgroup { margin-bottom: 2rem; padding-bottom: 0.5rem; border-bottom: 0.046rem solid var(--grey); +} + + + +.activity__item { + display: grid; + grid-template-columns: 0.25fr 2fr 0.25fr; + column-gap: 0.5rem; + margin-bottom: 1rem; } \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index 4e7d227..9ec42f9 100644 --- a/templates/base.html +++ b/templates/base.html @@ -27,7 +27,6 @@