Skip to content

Commit

Permalink
New Backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Prater-12 committed Feb 5, 2024
1 parent 8607bd3 commit 5f63f4a
Show file tree
Hide file tree
Showing 118 changed files with 320 additions and 252 deletions.
70 changes: 0 additions & 70 deletions backend/.gitignore

This file was deleted.

126 changes: 0 additions & 126 deletions backend/accounts/models.py

This file was deleted.

16 changes: 2 additions & 14 deletions backend/backend/settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Django settings for backend project.
Generated by 'django-admin startproject' using Django 4.2.1.
Generated by 'django-admin startproject' using Django 4.2.6.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/topics/settings/
Expand All @@ -21,7 +21,6 @@
"CURRENT_ACTIVE_SEASON_ID": 1,
}


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/

Expand All @@ -46,11 +45,6 @@
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"rest_framework",
"drf_yasg",
"accounts",
"projects",
"dashboard",
]

MIDDLEWARE = [
Expand Down Expand Up @@ -125,8 +119,6 @@
},
]

AUTH_USER_MODEL = "accounts.User"


# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/
Expand All @@ -143,12 +135,8 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/

STATIC_ROOT = BASE_DIR / "static"
STATIC_URL = "/static/"
MEDIA_URL = "/media/"
MEDIA_ROOT = BASE_DIR / "media"
STATIC_URL = "static/"

# Add the 'django.contrib.staticfiles' app to your INSTALLED_APPS.
# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field

Expand Down
37 changes: 1 addition & 36 deletions backend/backend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,9 @@
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path
from drf_yasg import openapi
from drf_yasg.views import get_schema_view
from rest_framework import permissions

schema_view = get_schema_view(
openapi.Info(
title="SoC Portal API",
default_version="v1",
description="Test description",
terms_of_service="https://www.google.com/policies/terms/",
contact=openapi.Contact(email="[email protected]"),
license=openapi.License(name="BSD License"),
),
permission_classes=[],
public=True,
)
from django.urls import path

urlpatterns = [
path("admin/", admin.site.urls),
path("api/accounts/", include("accounts.urls")),
path("api/dashboard/", include("dashboard.urls")),
path("api/projects/", include("projects.urls")),
]

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += [
path(
"swagger<format>/", schema_view.without_ui(cache_timeout=0), name="schema-json"
),
path(
"swagger/",
schema_view.with_ui("swagger", cache_timeout=0),
name="schema-swagger-ui",
),
path("redoc/", schema_view.with_ui("redoc", cache_timeout=0), name="schema-redoc"),
]
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
45 changes: 45 additions & 0 deletions backend_old/accounts/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from django.apps import apps
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
from django.contrib.auth.hashers import make_password
from django.contrib.auth.models import PermissionsMixin, User
from django.core.mail import send_mail
from django.db import models
from django.utils import timezone


class User(models.Model):
"""
An extension of
roll_number and password are required. Other fields are optional.
"""

user = models.OneToOneField(User, on_delete=models.CASCADE)
roll_number = models.CharField(
"roll number",
max_length=20,
unique=True,
help_text="Required. 20 characters or fewer.",
error_messages={
"unique": "A user with that roll number already exists.",
},
)

def clean(self):
super().clean()
self.email = self.__class__.objects.normalize_email(self.email)

def get_full_name(self):
"""
Return the first_name plus the last_name, with a space in between.
"""
full_name = "%s %s" % (self.first_name, self.last_name)
return full_name.strip()

def get_short_name(self):
"""Return the short name for the user."""
return self.first_name

def email_user(self, subject, message, from_email=None, **kwargs):
"""Send an email to this user."""
send_mail(subject, message, from_email, [self.email], **kwargs)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions backend_old/backend/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for 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/4.2/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "backend.settings")

application = get_asgi_application()
Loading

0 comments on commit 5f63f4a

Please sign in to comment.