From 286161b0912007c6f3859868a006e9818752a4aa Mon Sep 17 00:00:00 2001 From: Dominic DiTaranto Date: Mon, 28 Oct 2024 11:36:09 -0400 Subject: [PATCH] init commit --- db.sqlite3 | Bin 0 -> 147456 bytes korabo/__init__.py | 0 korabo/__pycache__/__init__.cpython-312.pyc | Bin 0 -> 152 bytes korabo/__pycache__/settings.cpython-312.pyc | Bin 0 -> 2627 bytes korabo/__pycache__/urls.cpython-312.pyc | Bin 0 -> 1320 bytes korabo/__pycache__/wsgi.cpython-312.pyc | Bin 0 -> 638 bytes korabo/asgi.py | 16 ++ korabo/settings.py | 127 ++++++++++++++++ korabo/template_filters.py | 6 + korabo/urls.py | 26 ++++ korabo/wsgi.py | 16 ++ manage.py | 22 +++ web/__init__.py | 0 web/__pycache__/__init__.cpython-312.pyc | Bin 0 -> 149 bytes web/__pycache__/admin.cpython-312.pyc | Bin 0 -> 447 bytes web/__pycache__/apps.cpython-312.pyc | Bin 0 -> 449 bytes web/__pycache__/models.cpython-312.pyc | Bin 0 -> 2680 bytes web/__pycache__/views.cpython-312.pyc | Bin 0 -> 5430 bytes web/admin.py | 6 + web/apps.py | 6 + web/migrations/0001_initial.py | 46 ++++++ .../0002_alter_availability_user.py | 21 +++ web/migrations/__init__.py | 0 .../__pycache__/0001_initial.cpython-312.pyc | Bin 0 -> 2163 bytes ...02_alter_availability_user.cpython-312.pyc | Bin 0 -> 1107 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 160 bytes web/models.py | 38 +++++ web/templates/base.html | 38 +++++ web/templates/event.html | 91 ++++++++++++ web/templates/index.html | 26 ++++ web/templates/registration/login.html | 1 + web/tests.py | 3 + web/views.py | 137 ++++++++++++++++++ 33 files changed, 626 insertions(+) create mode 100644 db.sqlite3 create mode 100644 korabo/__init__.py create mode 100644 korabo/__pycache__/__init__.cpython-312.pyc create mode 100644 korabo/__pycache__/settings.cpython-312.pyc create mode 100644 korabo/__pycache__/urls.cpython-312.pyc create mode 100644 korabo/__pycache__/wsgi.cpython-312.pyc create mode 100644 korabo/asgi.py create mode 100644 korabo/settings.py create mode 100644 korabo/template_filters.py create mode 100644 korabo/urls.py create mode 100644 korabo/wsgi.py create mode 100755 manage.py create mode 100644 web/__init__.py create mode 100644 web/__pycache__/__init__.cpython-312.pyc create mode 100644 web/__pycache__/admin.cpython-312.pyc create mode 100644 web/__pycache__/apps.cpython-312.pyc create mode 100644 web/__pycache__/models.cpython-312.pyc create mode 100644 web/__pycache__/views.cpython-312.pyc create mode 100644 web/admin.py create mode 100644 web/apps.py create mode 100644 web/migrations/0001_initial.py create mode 100644 web/migrations/0002_alter_availability_user.py create mode 100644 web/migrations/__init__.py create mode 100644 web/migrations/__pycache__/0001_initial.cpython-312.pyc create mode 100644 web/migrations/__pycache__/0002_alter_availability_user.cpython-312.pyc create mode 100644 web/migrations/__pycache__/__init__.cpython-312.pyc create mode 100644 web/models.py create mode 100644 web/templates/base.html create mode 100644 web/templates/event.html create mode 100644 web/templates/index.html create mode 100644 web/templates/registration/login.html create mode 100644 web/tests.py create mode 100644 web/views.py diff --git a/db.sqlite3 b/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..c754ade475908d7fd6d419fe73a4b37ffabb5287 GIT binary patch literal 147456 zcmeI5du$uYeaE>ZC5o2FwJqs*KEKwol{2H0v=1&Hx?Xa$C0h^cZQ0hP2X;xWD9U`9 z56RNyTFCcEku?9LXn+=I(*iB}M~fmY0t9H10!>h)540(Yq-fKmX!}nP1ZkQ8$pK9Y zbY^zRT|Oi^muqrXzXUwy&iv*#zu#wOmfGLU?yfH1%2st@qgc*sRY7r_ba0&GML}>l z93LV7u8@EA&o%PJT|XfIbGGjXef@}IZ0|uA73P0PWdg>32Z<9wRGS$j-;OWT_l>?!^xf$@ z)%&I1H+q+P1tN$K2!H?xfB*=900@8p2)v64ylmTSn%f-Fub z(u5?ADWW1pWaV_1EqE{-}VxdABJ)n{tn-IfeVk{C?!qca^9D{e`TCKWCnC}M9G?|M2wkAm_s@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b_&?*SS+)+BeS?cg3E8j0r zGuQIub&xZjDVck=k-?ZA3X?al5Pm?5LeRfWt2Y5VQo<#Vg8g|kp;@wDu385rd*upz zKb_}|t#ZGQvX;fLUk2%Qd;D=R#($kUt}Rv&_I{y_@5p)Uop|5S>L;{%w&tI$Z+}6L Qf3)s=Zrwd;X4h@ge;#nT$N&HU literal 0 HcmV?d00001 diff --git a/korabo/asgi.py b/korabo/asgi.py new file mode 100644 index 0000000..78c0d6c --- /dev/null +++ b/korabo/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for korabo project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'korabo.settings') + +application = get_asgi_application() diff --git a/korabo/settings.py b/korabo/settings.py new file mode 100644 index 0000000..cd4f4e7 --- /dev/null +++ b/korabo/settings.py @@ -0,0 +1,127 @@ +""" +Django settings for korabo project. + +Generated by 'django-admin startproject' using Django 5.1.2. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/5.1/ref/settings/ +""" + +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-2zbb@9m=%exl38+&(1*4lp5dz(kg__p9uqba0junq096h6i^ni' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'web', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'bootstrap5' +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'korabo.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': ['web/templates'], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'korabo.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/5.1/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/5.1/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/5.1/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' +LOGIN_REDIRECT_URL = '/' +LOGOUT_REDIRECT_URL = '/' diff --git a/korabo/template_filters.py b/korabo/template_filters.py new file mode 100644 index 0000000..c3a3af8 --- /dev/null +++ b/korabo/template_filters.py @@ -0,0 +1,6 @@ +from django.template.defaulttags import register + + +@register.filter +def get_item(dictionary, key): + return dictionary.get(key) \ No newline at end of file diff --git a/korabo/urls.py b/korabo/urls.py new file mode 100644 index 0000000..fbbfded --- /dev/null +++ b/korabo/urls.py @@ -0,0 +1,26 @@ +""" +URL configuration for korabo project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/5.1/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path, include +from web import views + +urlpatterns = [ + path("accounts/", include("django.contrib.auth.urls")), + path('admin/', admin.site.urls), + path("", views.index, name="index"), + path("event/", views.event, name="event"), +] diff --git a/korabo/wsgi.py b/korabo/wsgi.py new file mode 100644 index 0000000..c132c75 --- /dev/null +++ b/korabo/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for korabo project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'korabo.settings') + +application = get_wsgi_application() diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..e797df2 --- /dev/null +++ b/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'korabo.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/web/__init__.py b/web/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/web/__pycache__/__init__.cpython-312.pyc b/web/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..dfdbe915c587ac715120e91927bff7722b97c380 GIT binary patch literal 149 zcmX@j%ge<81Zz1Y(n0iN5P=Rpvj9b=GgLBYGWxA#C}INgK7-W!GSSb-&rQ`&$JmtkIamWj77{q762fbBFO*% literal 0 HcmV?d00001 diff --git a/web/__pycache__/admin.cpython-312.pyc b/web/__pycache__/admin.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9b5bd4aee512f9b48e9e288dd36fb4e839229175 GIT binary patch literal 447 zcmb7Aze~eF6n@vsl@QW8baB*0$dcgFK}6`#O{A;Y^5bYP=5lh0m5ffV;-b5g^iSzj zP?Q64aB?ejbMmel>gpTb_r34<-jADiIu7VKb+^Y48b3_Yg!M~Sx0>8R3MtBgqYxp( zTX~D)5OXWEI0*>?iZZvcZZO;0@P<)Lty$}*`j?N)P~)nxXMLK&LyANxXN89q8BS?Y zDQ67>BPw?=jaVMVEN4}H;@PU3W>GN~ejLphf;_PI!DUP^PeBqp`ZlU1^c zDqGSqD=R7=VWn00+7Bjz(;yXk2up%dolGLhM^a=osmkC?$S4+pZX2wZ^UrH#ALmhrnyj`YSO5nbF|aj;Y|J!U&#|Ew ztt;+S*1J76rI9C0=9r;iJV?z`-y38zapCiT75J7rL!(hN35jUP2`Soy$iXa7xJ$@Q zMuS?}WPD7sU`D94lX2q3aBi)1Zhu}IV^XN-t_Hdr+FR4l^RY`qegwQ+ef3In1U literal 0 HcmV?d00001 diff --git a/web/__pycache__/models.cpython-312.pyc b/web/__pycache__/models.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..47d02ccdca849437dd8ce7babdccf1e9f0fa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`io~&vz8|a> zfKY^nOh_bgRc{Fr>DILbNpI_#gl?^ra~tBRjlLnQDdNqNSqQJW(jd@%!>VU4b6BU%63%&_%{p2sy$Ou*+-aSpP|Tad5B%y~YI zq4I_-t0#uAu^7+wBms3S((4YWI-1}e?zkeK5{hZ$>0F~v)=UBm36x9=)5Um6GK5yK zwjv?1o5ja7+(zj6swtaGJ&X7iowOm+XoO#x-s|*zlRPk*0gJ?9&WGI7THv} zL?fndMw*rizOdp8-}h~wbmUAqUUihqp60xxS#{RVjwsHp1!qKYM&`vYoLx(1#I(S@ zx4N--FE22i3e$P}dot6RXATsY0fiZmkG)qD>N5UTw5S!Z*Iw%@6n7(mtD0_+TU~Pr{zd^ljhkY)lmNoT}O3n?fX&fsbv1UJ4Xbx?UNOgs;&gw~>@r%-VrvF60vijt@oH zF>xfq@iF*5A!e|E$?aMHBvITAV#AM-E<>qwg0;qy{60JaC{kz&1JErQDT?|EHGGY> xeT{a1g#urp7am!V!Ih^f9vR%!j>kr1a4(U!N83u^lhg`ae@z;^RHeSwe*ozZ*-QWc literal 0 HcmV?d00001 diff --git a/web/admin.py b/web/admin.py new file mode 100644 index 0000000..9c6efc5 --- /dev/null +++ b/web/admin.py @@ -0,0 +1,6 @@ +from django.contrib import admin +from web.models import Event, EventAdmin, Availability + + +admin.site.register(Event, EventAdmin) +admin.site.register(Availability) diff --git a/web/apps.py b/web/apps.py new file mode 100644 index 0000000..682e923 --- /dev/null +++ b/web/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class WebConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'web' diff --git a/web/migrations/0001_initial.py b/web/migrations/0001_initial.py new file mode 100644 index 0000000..5107a35 --- /dev/null +++ b/web/migrations/0001_initial.py @@ -0,0 +1,46 @@ +# Generated by Django 5.1.2 on 2024-10-22 20:31 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Event', + fields=[ + ('created_at', models.DateTimeField(auto_now_add=True, null=True)), + ('updated_at', models.DateTimeField(auto_now=True, null=True)), + ('active', models.BooleanField(default=True)), + ('id', models.AutoField(primary_key=True, serialize=False)), + ('name', models.TextField()), + ('start_date', models.DateTimeField()), + ('end_date', models.DateTimeField()), + ('participants', models.IntegerField()), + ], + options={ + 'db_table': 'events', + }, + ), + migrations.CreateModel( + name='Availability', + fields=[ + ('created_at', models.DateTimeField(auto_now_add=True, null=True)), + ('updated_at', models.DateTimeField(auto_now=True, null=True)), + ('active', models.BooleanField(default=True)), + ('id', models.AutoField(primary_key=True, serialize=False)), + ('user', models.TextField()), + ('time_table', models.JSONField()), + ('event_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='web.event')), + ], + options={ + 'db_table': 'availabilities', + }, + ), + ] diff --git a/web/migrations/0002_alter_availability_user.py b/web/migrations/0002_alter_availability_user.py new file mode 100644 index 0000000..4fdf65b --- /dev/null +++ b/web/migrations/0002_alter_availability_user.py @@ -0,0 +1,21 @@ +# Generated by Django 4.2.16 on 2024-10-24 17:59 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('web', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='availability', + name='user', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/web/migrations/__init__.py b/web/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/web/migrations/__pycache__/0001_initial.cpython-312.pyc b/web/migrations/__pycache__/0001_initial.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f6f6b17830c1f712c2c697efb10daf0f1f726d7f GIT binary patch literal 2163 zcmdT_J#5=X6h2ZCMbWZMIkIF$QE0aYT%iGF*N$5OX#v+ish!$Q9ixL5g3_H8$`q-R zlv8C&feab5#bejP9x|p=vlIx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2Hdo6|Th!o0=Xf+pCaCdR&Cr8J2L%K(W70Hv@{zmpWY{+ArS%^mh%Vp|=y*b=hzt8ce-imRns#4CKdNQ zOc*iaI*{p#eN1`ZEecHYNN4EiHl|{1Q#&TM&{{D^Wf;dHqzZ(Lw`XC7vk<=B)2)aL zArV=3bkN(^8x6h6@(4GugRoO;l4#y^puAmq0k^jnH{t5~!r}_eUNKDUQKfA8m@Gwq zB+<@MWyvMjG@MtsNhMU*9mAzOs!}=bnym&+&zHC6%L|KCaT~b1E+^oeT?T)*O1rL& zOUSjE47Jimv$m@fdxN-jT=Tus8<*%+x5UIMU9Vb+$@UcLQ6KQ8W-yXWZ8S-mRgO)x zVjf}U0JJ5LDST8yc{-4%kL9p17Zm2c$>o+j-cAXF()*Qm7G%aE#%LgqwuTq9Px*Vv>p}HQZ>t8Fc!-^GDtnYdIA}wZ=wjkxD4=>4h z(nL|FeH~rYn(ORzRL*oGs2UHXBjxZ_Q0+V>HPMg^C)LPUgyP~83{m-cXU?-^in-BC m@g6eM7C4T(lmPeOCn)>?6BklHCmkwbZYs!4T>|FBHU0w);tM;L8i$RQ!%#4hTMa)1J01{LuKmY&$ literal 0 HcmV?d00001 diff --git a/web/models.py b/web/models.py new file mode 100644 index 0000000..f303552 --- /dev/null +++ b/web/models.py @@ -0,0 +1,38 @@ +from django.contrib import admin +from django.db import models +from django.contrib.auth.models import User + + + +class BaseModel(models.Model): + created_at = models.DateTimeField(blank=True, null=True, auto_now_add=True) + updated_at = models.DateTimeField(blank=True, null=True, auto_now=True) + active = models.BooleanField(default=True) + + class Meta: + abstract = True + + +class Event(BaseModel): + id = models.AutoField(primary_key=True) + name = models.TextField(blank=False, null=False) + start_date = models.DateTimeField(blank=False, null=False) + end_date = models.DateTimeField(blank=False, null=False) + participants = models.IntegerField(blank=False) + + class Meta: + db_table = 'events' + + +class EventAdmin(admin.ModelAdmin): + list_display = ('name', 'start_date', 'end_date', 'active') + + +class Availability(BaseModel): + id = models.AutoField(primary_key=True) + event_id = models.ForeignKey(Event, on_delete=models.CASCADE) + user = models.ForeignKey(User, on_delete=models.CASCADE) + time_table = models.JSONField() + + class Meta: + db_table = 'availabilities' diff --git a/web/templates/base.html b/web/templates/base.html new file mode 100644 index 0000000..d6ba2da --- /dev/null +++ b/web/templates/base.html @@ -0,0 +1,38 @@ + + + + + Korabo + {% load static %} + {% load bootstrap5 %} + {% bootstrap_css %} + {% bootstrap_javascript %} + + + +
+ +

Korabo

+
+ + ~make it easy with コラボ~ +
+
+ home | + logout + +
+ +
+
+ +
+ {% block content %}{% endblock %} +
+ +
+ Version 1.0 | Created By Dominic DiTaranto | Questions/Suggestions: me@domdit.com | Last Update 09/22/2024 +
+ + + \ No newline at end of file diff --git a/web/templates/event.html b/web/templates/event.html new file mode 100644 index 0000000..60535c7 --- /dev/null +++ b/web/templates/event.html @@ -0,0 +1,91 @@ +{% extends 'base.html' %} + +{% block content %} + +

{{event.name}}

+
{% csrf_token %} + +
+ + + + + {% for datetime, day in morning.items %} + + {% endfor %} + + + + + + {% for datetime, day in morning.items %} + + + {% endfor %} + + + + {% for datetime, day in noon.items %} + + {% endfor %} + + + + {% for datetime, day in night.items %} + + {% endfor %} + + +
#{{ datetime }}
Morning +
+ {{ day.1 }} +
Afternoon +
+ {{ day.1 }} +
Night +
+ {{ day.1 }} +
+
+ +
+
+ Responses: {{user_responses}} / {{event.participants}} +
+
+ +
+
+ +
+ +
+
+
+

Best Times

+ {{ no_overlap_message }} + {% for day, users in best_days.items %} +
+
{{day}}
+
{{users}}
+
+ {% endfor %} +
+ + + + + + + +

+ + +{% endblock %} diff --git a/web/templates/index.html b/web/templates/index.html new file mode 100644 index 0000000..5f2150b --- /dev/null +++ b/web/templates/index.html @@ -0,0 +1,26 @@ +{% extends 'base.html' %} + +{% block content %} + + + + + + + + + + + + {% for event in events %} + + + + + + + {% endfor %} + +
Event NameAlready RespondedStart DateEnd Date
{{event.name}}{{event.responses}}{{event.start_date}}{{event.end_date}}
+ +{% endblock %} diff --git a/web/templates/registration/login.html b/web/templates/registration/login.html new file mode 100644 index 0000000..afdff9b --- /dev/null +++ b/web/templates/registration/login.html @@ -0,0 +1 @@ +{% extends "admin/login.html" %} diff --git a/web/tests.py b/web/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/web/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/web/views.py b/web/views.py new file mode 100644 index 0000000..cc537c4 --- /dev/null +++ b/web/views.py @@ -0,0 +1,137 @@ +from django.shortcuts import render +from web.models import Event, Availability +from django.shortcuts import get_object_or_404, redirect +from datetime import timedelta +from django.contrib.auth.decorators import login_required + + +@login_required() +def index(request): + parsed_events = [] + + for active_event in Event.objects.filter(active=True).order_by('start_date'): + data = { + 'id': active_event.id, + 'name': active_event.name, + 'start_date': active_event.start_date, + 'end_date': active_event.end_date, + 'responses': ', '.join([x.user.username for x in active_event.availability_set.all()]) + } + + parsed_events.append(data) + + context = { + 'events': parsed_events + } + + return render(request, "index.html", context) + + +@login_required() +def event(request, event_id): + + event = get_object_or_404(Event, pk=event_id) + + if request.method == 'POST': + handle_availability_update(event, request) + return redirect('event', event_id=event_id) + + elif request.method == 'GET': + day_count = (event.end_date - event.start_date).days + 1 + morning = {} + noon = {} + night = {} + all_availabilities = {} + requesting_user_submitted = False + + context = { + 'event': event, + 'morning': morning, + 'noon': noon, + 'night': night, + 'user_availability': None, + 'active_dates': None, + 'user_responses': 0, + 'best_days': {}, + 'no_overlap_message': '' + } + + user_availability = Availability.objects.filter(event_id=event) + if user_availability: + for user_avail in user_availability: + context['user_responses'] += 1 + + for time in user_avail.time_table.get('active', []): + if time not in all_availabilities: + all_availabilities[time] = [] + + all_availabilities[time].append(user_avail.user.username) + + if request.user == user_avail.user: + requesting_user_submitted = True + context['active_dates'] = user_avail.time_table['active'] + + context['all_availabilities'] = all_availabilities + + for i in range(day_count): + date = event.start_date + timedelta(days=i) + + human_readable_date = date.strftime('%m/%d/%Y %A') + for idx, time_period_array in enumerate([morning, noon, night]): + date_id = date.strftime(f'%m/%d/%Y %A-{idx}') + users = ', '.join(all_availabilities.get(date_id, [])) + + if not requesting_user_submitted: + users = '' + + time_period_array[human_readable_date] = (date_id, users) + + if all_availabilities: + most_avail = None + for day in sorted(all_availabilities, key=lambda k: len(all_availabilities[k]), reverse=True): + if not most_avail: + most_avail = len(all_availabilities[day]) + + if len(all_availabilities[day]) >= most_avail - 1 and len(all_availabilities[day]) != 1: + + day_arr = day.split('-') + if day_arr[-1] == '0': + hday = day_arr[0] + ' Morning' + + if day_arr[-1] == '1': + hday = day_arr[0] + ' Noon' + + if day_arr[-1] == '2': + hday = day_arr[0] + ' Night' + + context['best_days'][hday] = ', '.join(all_availabilities[day]) + + if not requesting_user_submitted: + all_availabilities = {} + + if context['best_days'] == {}: + context['no_overlap_message'] = 'There are currently no overlapping times or dates!' + + return render(request, "event.html", context) + +def handle_availability_update(event, request): + availability_data = { + 'active': [] + } + + for date, value in request.POST.items(): + if date != 'csrfmiddlewaretoken': + availability_data['active'].append(date) + + user_availability = Availability.objects.filter(event_id=event).filter(user=request.user) + if not user_availability: + a = Availability( + event_id=event, + user=request.user, + time_table=availability_data + ) + a.save() + else: + avail = user_availability[0] + avail.time_table = availability_data + avail.save()