Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
venv/*

.env

*.pyc
__pycache__/

db.sqlite3
10 changes: 10 additions & 0 deletions account/Serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from rest_framework.serializers import ModelSerializer

from .models import User


class RegisterSerializer(ModelSerializer):

class Meta:
model = User
fields = '__all__'
Empty file added account/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions account/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.contrib import admin
from .models import User

# Register your models here.
admin.site.register(User)
5 changes: 5 additions & 0 deletions account/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class AccountConfig(AppConfig):
name = 'account'
31 changes: 31 additions & 0 deletions account/management/commands/create_admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from django.core.management.base import BaseCommand
from django.contrib.auth import get_user_model


User = get_user_model()

class Command(BaseCommand):

def handle(self, *args, **kwargs):

username = input("Username: ")
email = input("Email: ")
password = input("Password: ")
confirm_password = input("Confirm Password: ")

if password != confirm_password:
self.stdout.write(self.style.ERROR("Passwords do not match"))
return

if User.objects.filter(username=username).exists():
self.stdout.write("User already exists")
return

User.objects.create_user(
username=username,
email=email,
password=password,
role="ADMIN"
)

self.stdout.write("Admin created successfully")
45 changes: 45 additions & 0 deletions account/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Generated by Django 6.0.6 on 2026-06-06 10:07

import django.contrib.auth.models
import django.contrib.auth.validators
import django.utils.timezone
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
('auth', '0012_alter_user_first_name_max_length'),
]

operations = [
migrations.CreateModel(
name='User',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('password', models.CharField(max_length=128, verbose_name='password')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')),
('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')),
('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
('role', models.CharField(choices=[('OWNER', 'Owner'), ('CUSTOMER', 'Customer')], default='CUSTOMER', max_length=20)),
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')),
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')),
],
options={
'verbose_name': 'user',
'verbose_name_plural': 'users',
'abstract': False,
},
managers=[
('objects', django.contrib.auth.models.UserManager()),
],
),
]
18 changes: 18 additions & 0 deletions account/migrations/0002_alter_user_role.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 6.0.6 on 2026-06-07 12:27

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('account', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='user',
name='role',
field=models.CharField(choices=[('ADMIN', 'Admin'), ('OWNER', 'Owner'), ('CUSTOMER', 'Customer')], default='CUSTOMER', max_length=20),
),
]
25 changes: 25 additions & 0 deletions account/migrations/0003_user_address_user_phone_no.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 6.0.6 on 2026-06-22 06:50

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('account', '0002_alter_user_role'),
]

operations = [
migrations.AddField(
model_name='user',
name='address',
field=models.TextField(default=1),
preserve_default=False,
),
migrations.AddField(
model_name='user',
name='phone_no',
field=models.CharField(default=1, max_length=13),
preserve_default=False,
),
]
Empty file added account/migrations/__init__.py
Empty file.
21 changes: 21 additions & 0 deletions account/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from django.db import models
from django.contrib.auth.models import AbstractUser


# Create your models here.

class User(AbstractUser):

class Role(models.TextChoices):
ADMIN = "ADMIN"
OWNER = "OWNER"
CUSTOMER = "CUSTOMER"


role = models.CharField(max_length=20,choices=Role.choices,default=Role.CUSTOMER)
address = models.TextField()
phone_no = models.CharField(max_length=13)




9 changes: 9 additions & 0 deletions account/permissions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from rest_framework.permissions import BasePermission


class IsAdminRole(BasePermission):
def has_permission(self, request, view):
return (
request.user.is_authenticated
and request.user.role_type == request.user.Role.ADMIN
)
3 changes: 3 additions & 0 deletions account/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
7 changes: 7 additions & 0 deletions account/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.urls import path

from .views import RegisterCreateView

urlpatterns = [
path('register/',RegisterCreateView.as_view())
]
36 changes: 36 additions & 0 deletions account/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from rest_framework.generics import CreateAPIView
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status

from .models import User
from .Serializers import RegisterSerializer,LoginUserSerializer


class RegisterCreateView(CreateAPIView):
serializer_class = RegisterSerializer
queryset = User.objects.all()


class LoginUserView(APIView):

def post(self, request):
log_serializer = LoginUserSerializer(data=request.data)
print(LoginUserSerializer(data=request.data))

if log_serializer.is_valid():
return Response(
{
"access": log_serializer.validated_data["access"],
"refresh": log_serializer.validated_data["refresh"],
"username": log_serializer.validated_data["user"].username,
},
status=status.HTTP_200_OK,
)
return Response(log_serializer.errors, status=status.HTTP_400_BAD_REQUEST)






Empty file added bkmyvenue_backend/__init__.py
Empty file.
16 changes: 16 additions & 0 deletions bkmyvenue_backend/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for bkmyvenue_backend 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/6.0/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'bkmyvenue_backend.settings')

application = get_asgi_application()
113 changes: 113 additions & 0 deletions bkmyvenue_backend/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
from pathlib import Path
from datetime import timedelta

BASE_DIR = Path(__file__).resolve().parent.parent


SECRET_KEY = 'django-insecure-smzs+(tun4nb82^$kme5j2w-=9-t-8eav0&ri=76yy3igbp_+t'

DEBUG = True

ALLOWED_HOSTS = []


INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework_simplejwt',
'rest_framework',
'account',
'locations',
'venues',
'bookings',
'reviews',
]

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 = 'bkmyvenue_backend.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'bkmyvenue_backend.wsgi.application'


DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}



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',
},
]



LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True

STATIC_URL = 'static/'

MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'media'

AUTH_USER_MODEL = "account.User"


SIMPLE_JWT = {
"ACCESS_TOKEN_LIFETIME": timedelta(minutes=60),
"REFRESH_TOKEN_LIFETIME": timedelta(days=1),

"AUTH_HEADER_TYPES": ("Bearer",),
}

REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_simplejwt.authentication.JWTAuthentication',
)
}
Loading