Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #34 from MaziniiX/main
Browse files Browse the repository at this point in the history
update
  • Loading branch information
MaziniiX authored Jun 21, 2024
2 parents 66fcfa9 + 29ce68e commit 2ac0e47
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 4 deletions.
10 changes: 10 additions & 0 deletions Django_Frontend/empty_db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
DO $$ DECLARE
r RECORD;
BEGIN
-- if the schema you operate on is not "current", you will want to
-- replace current_schema() in query with 'schematodeletetablesfrom'
-- *and* update the generate 'DROP...' accordingly.
FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) LOOP
EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(r.tablename) || ' CASCADE';
END LOOP;
END $$;
5 changes: 3 additions & 2 deletions Django_Frontend/monprojet/monapp/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.http import HttpRequest
import requests
from django.shortcuts import render, redirect
from django.views.decorators.csrf import csrf_exempt
from django.contrib import messages
from django.contrib.auth.models import User
from .forms import ClientForm, StaffForm, StaffTypeForm, RegistrationForm
Expand All @@ -12,7 +12,7 @@
def get_api_url(request: HttpRequest) -> str:
host = request.get_host()
protocol = 'https://' if request.is_secure() else 'http://'
api_url = f'{protocol}api.{host}/'
api_url = f'{protocol}{host}/'
return api_url

def client_create_view(request):
Expand Down Expand Up @@ -64,6 +64,7 @@ def register(request):
form = RegistrationForm()
return render(request, 'monapp/register.html', {'form': form})

@csrf_exempt
def login(request):
api_url = get_api_url(request)
if request.method == 'POST':
Expand Down
4 changes: 3 additions & 1 deletion Django_Frontend/monprojet/monprojet/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
]

if ENVIRONMENT != 'development':
CSRF_TRUSTED_ORIGINS = ["https://" + os.getenv('DOMAIN')]
CSRF_TRUSTED_ORIGINS = ["https://" + os.getenv('DOMAIN'), "https://api." + os.getenv('DOMAIN')]
else:
CSRF_TRUSTED_ORIGINS = ['*']

ROOT_URLCONF = 'monprojet.urls'

Expand Down
4 changes: 3 additions & 1 deletion Django_api/airline/airline/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@
]

if ENVIRONMENT != 'development':
CSRF_TRUSTED_ORIGINS = ["https://api." + os.getenv('DOMAIN')]
CSRF_TRUSTED_ORIGINS = ["https://" + os.getenv('DOMAIN'), "https://api." + os.getenv('DOMAIN')]
else:
CSRF_TRUSTED_ORIGINS = ['*']

ROOT_URLCONF = 'airline.urls'

Expand Down
21 changes: 21 additions & 0 deletions Django_api/airline/api_common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@
from django.db import models
from django.contrib.auth.models import User


############# DO NOT TOUCH THE CODE BELOW THIS LINE #############
class Client(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
is_staff = models.BooleanField(default=False)
is_superuser = models.BooleanField(default=False)

class Meta:
db_table = 'client'

class Staff(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
is_staff = models.BooleanField(default=False)
is_superuser = models.BooleanField(default=False)
staff_type = models.ForeignKey('StaffType', on_delete=models.CASCADE)

class Meta:
db_table = 'staff'
############# DO NOT TOUCH THE CODE ABOVE THIS LINE #############


class StaffType(models.Model):
type = models.CharField(max_length=100)

Expand Down

0 comments on commit 2ac0e47

Please sign in to comment.