From 286161b0912007c6f3859868a006e9818752a4aa Mon Sep 17 00:00:00 2001 From: Dominic DiTaranto Date: Mon, 28 Oct 2024 11:36:09 -0400 Subject: 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 +++++++ web/migrations/0002_alter_availability_user.py | 21 ++++ web/migrations/__init__.py | 0 .../__pycache__/0001_initial.cpython-312.pyc | Bin 0 -> 2163 bytes .../0002_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 0000000..c754ade Binary files /dev/null and b/db.sqlite3 differ diff --git a/korabo/__init__.py b/korabo/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/korabo/__pycache__/__init__.cpython-312.pyc b/korabo/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..ff53bd8 Binary files /dev/null and b/korabo/__pycache__/__init__.cpython-312.pyc differ diff --git a/korabo/__pycache__/settings.cpython-312.pyc b/korabo/__pycache__/settings.cpython-312.pyc new file mode 100644 index 0000000..d48b1e7 Binary files /dev/null and b/korabo/__pycache__/settings.cpython-312.pyc differ diff --git a/korabo/__pycache__/urls.cpython-312.pyc b/korabo/__pycache__/urls.cpython-312.pyc new file mode 100644 index 0000000..66d8688 Binary files /dev/null and b/korabo/__pycache__/urls.cpython-312.pyc differ diff --git a/korabo/__pycache__/wsgi.cpython-312.pyc b/korabo/__pycache__/wsgi.cpython-312.pyc new file mode 100644 index 0000000..dd689e4 Binary files /dev/null and b/korabo/__pycache__/wsgi.cpython-312.pyc differ 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 0000000..dfdbe91 Binary files /dev/null and b/web/__pycache__/__init__.cpython-312.pyc differ diff --git a/web/__pycache__/admin.cpython-312.pyc b/web/__pycache__/admin.cpython-312.pyc new file mode 100644 index 0000000..9b5bd4a Binary files /dev/null and b/web/__pycache__/admin.cpython-312.pyc differ diff --git a/web/__pycache__/apps.cpython-312.pyc b/web/__pycache__/apps.cpython-312.pyc new file mode 100644 index 0000000..90ab549 Binary files /dev/null and b/web/__pycache__/apps.cpython-312.pyc differ diff --git a/web/__pycache__/models.cpython-312.pyc b/web/__pycache__/models.cpython-312.pyc new file mode 100644 index 0000000..47d02cc Binary files /dev/null and b/web/__pycache__/models.cpython-312.pyc differ diff --git a/web/__pycache__/views.cpython-312.pyc b/web/__pycache__/views.cpython-312.pyc new file mode 100644 index 0000000..4591619 Binary files /dev/null and b/web/__pycache__/views.cpython-312.pyc differ 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 0000000..f6f6b17 Binary files /dev/null and b/web/migrations/__pycache__/0001_initial.cpython-312.pyc differ diff --git a/web/migrations/__pycache__/0002_alter_availability_user.cpython-312.pyc b/web/migrations/__pycache__/0002_alter_availability_user.cpython-312.pyc new file mode 100644 index 0000000..70e69e8 Binary files /dev/null and b/web/migrations/__pycache__/0002_alter_availability_user.cpython-312.pyc differ diff --git a/web/migrations/__pycache__/__init__.cpython-312.pyc b/web/migrations/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..b45851f Binary files /dev/null and b/web/migrations/__pycache__/__init__.cpython-312.pyc differ 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() -- cgit v1.2.3-70-g09d2