Skip to content

Commit

Permalink
Ref #161 - Configure project for postgresql and add models for User, …
Browse files Browse the repository at this point in the history
…Post and EventPost
  • Loading branch information
Kerem Zaman committed Nov 12, 2021
1 parent 4d241b7 commit 76fcd92
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 4 deletions.
2 changes: 1 addition & 1 deletion backend/app/apps/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

class AppsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'apps'
name = 'app.apps'
63 changes: 62 additions & 1 deletion backend/app/apps/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,64 @@
from django.db import models

# Create your models here.

class User(models.Model):

id = models.BigAutoField(primary_key=True)

username = models.TextField()
email = models.TextField()
password = models.CharField(max_length=64)

first_name = models.TextField()
last_name = models.TextField()
bio = models.TextField()

birthday = models.DateTimeField()

avatar = models.TextField()
location = models.TextField()

fav_sport_1 = models.TextField()
fav_sport_2 = models.TextField()
fav_sport_3 = models.TextField()

badge_1 = models.TextField()
badge_2 = models.TextField()
badge_3 = models.TextField()

privacy = models.BooleanField()


class Post(models.Model):

id = models.BigAutoField(primary_key=True)
owner = models.ForeignKey(User, on_delete=models.CASCADE)

content = models.TextField()
title = models.TextField()

creation_date = models.DateTimeField()
location = models.TextField()

class Meta:
abstract = True


class EventPost(Post):
date = models.DateTimeField()
duration = models.TimeField()

sport = models.CharField(max_length=30)
age_group = models.IntegerField()

player_capacity = models.IntegerField()
spec_capacity = models.IntegerField()
players = models.IntegerField()
spectators = models.IntegerField()

skill_level = models.TextChoices('skill_level', 'Beginner Preintermediate Intermediate Advanced Expert')

latitude = models.FloatField()
longitude = models.FloatField()


10 changes: 8 additions & 2 deletions backend/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""

from pathlib import Path
import os

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
Expand All @@ -31,6 +32,7 @@
# Application definition

INSTALLED_APPS = [
'app.apps',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
Expand Down Expand Up @@ -74,8 +76,12 @@

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ.get('POSTGRES_DB', None),
'USER': os.environ.get('POSTGRES_USER', None),
'PASSWORD': os.environ.get('POSTGRES_PASSWORD', None),
'HOST': 'localhost' if DEBUG else 'database',
'PORT': ''#5432
}
}

Expand Down

0 comments on commit 76fcd92

Please sign in to comment.