diff --git a/api_v1/admin.py b/api_v1/admin.py index 8718f5b..fbf5b6a 100644 --- a/api_v1/admin.py +++ b/api_v1/admin.py @@ -3,6 +3,7 @@ from django.contrib import admin from api_v1.cafeteria.model import Cafeteria from api_v1.institution.model import Institution from api_v1.location.model import Location +from api_v1.mood.model import Mood from api_v1.profile.model import Profile # Register your models here. @@ -10,3 +11,4 @@ admin.site.register(Profile) admin.site.register(Location) admin.site.register(Cafeteria) admin.site.register(Institution) +admin.site.register(Mood) diff --git a/api_v1/migrations/0006_addedMoodModel.py b/api_v1/migrations/0006_addedMoodModel.py new file mode 100644 index 0000000..96cd4c0 --- /dev/null +++ b/api_v1/migrations/0006_addedMoodModel.py @@ -0,0 +1,27 @@ +# Generated by Django 5.0.2 on 2024-02-28 22:55 + +import colorfield.fields +import uuid +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('api_v1', '0005_addedInstitutionModel'), + ] + + operations = [ + migrations.CreateModel( + name='Mood', + fields=[ + ('mood_id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), + ('name', models.CharField(max_length=30)), + ('description', models.CharField(max_length=150)), + ('color', colorfield.fields.ColorField(default='#FFFFFF', image_field=None, max_length=25, samples=None)), + ('is_available', models.BooleanField(default=True)), + ('is_reliable', models.BooleanField(default=True)), + ('is_going', models.BooleanField(default=False)), + ], + ), + ] diff --git a/api_v1/models.py b/api_v1/models.py index 1cb81d8..9675678 100644 --- a/api_v1/models.py +++ b/api_v1/models.py @@ -2,3 +2,4 @@ from api_v1.profile.model import Profile from api_v1.location.model import Location from api_v1.cafeteria.model import Cafeteria from api_v1.institution.model import Institution +from api_v1.mood.model import Mood diff --git a/api_v1/mood/__init__.py b/api_v1/mood/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/api_v1/mood/model.py b/api_v1/mood/model.py new file mode 100644 index 0000000..c0ad489 --- /dev/null +++ b/api_v1/mood/model.py @@ -0,0 +1,20 @@ +import uuid + +from django.db import models +from colorfield.fields import ColorField + + +class Mood(models.Model): + mood_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) + + name = models.CharField(max_length=30) + description = models.CharField(max_length=150, blank=False, null=False) + + color = ColorField(format='hex') + + is_available = models.BooleanField(default=True) # Is available to go + is_reliable = models.BooleanField(default=True) # Will always do the same in this mood + is_going = models.BooleanField(default=False) # Is going to the cafeteria + + def __str__(self): + return self.name diff --git a/mixr_api/settings.py b/mixr_api/settings.py index 86b866b..2638700 100644 --- a/mixr_api/settings.py +++ b/mixr_api/settings.py @@ -15,7 +15,6 @@ 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.0/howto/deployment/checklist/ @@ -27,18 +26,19 @@ DEBUG = True ALLOWED_HOSTS = [] - # Application definition INSTALLED_APPS = [ - 'api_v1.apps.ApiV1Config', - 'rest_framework', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + + 'api_v1.apps.ApiV1Config', + 'rest_framework', + 'colorfield', ] MIDDLEWARE = [ @@ -71,7 +71,6 @@ TEMPLATES = [ WSGI_APPLICATION = 'mixr_api.wsgi.application' - # Database # https://docs.djangoproject.com/en/5.0/ref/settings/#databases @@ -86,7 +85,6 @@ DATABASES = { } } - # Password validation # https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators @@ -105,7 +103,6 @@ AUTH_PASSWORD_VALIDATORS = [ }, ] - # Internationalization # https://docs.djangoproject.com/en/5.0/topics/i18n/ @@ -117,7 +114,6 @@ USE_I18N = True USE_TZ = True - # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/5.0/howto/static-files/ diff --git a/requirements.txt b/requirements.txt index a2157e3..b62a3f8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ Django~=4.2 psycopg2-binary~=2.9.9 -djangorestframework~=3.14.0 \ No newline at end of file +djangorestframework~=3.14.0 +django-colorfield~=0.11.0 \ No newline at end of file