Skip to content

Commit 9beed0a

Browse files
committed
first commit
0 parents  commit 9beed0a

File tree

115 files changed

+4395
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+4395
-0
lines changed

GEHU_Book_Store/__init__.py

Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
714 Bytes
Binary file not shown.

GEHU_Book_Store/asgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for GEHU_Book_Store project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'GEHU_Book_Store.settings')
15+
16+
application = get_asgi_application()

GEHU_Book_Store/settings.py

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
"""
2+
Django settings for GEHU_Book_Store project.
3+
4+
Generated by 'django-admin startproject' using Django 4.1.7.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.1/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/4.1/ref/settings/
11+
"""
12+
import os
13+
from pathlib import Path
14+
import dj_database_url
15+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
16+
BASE_DIR = Path(__file__).resolve().parent.parent
17+
18+
19+
# Quick-start development settings - unsuitable for production
20+
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
21+
22+
# SECURITY WARNING: keep the secret key used in production secret!
23+
SECRET_KEY = 'django-insecure-=c*+4x4au55j3!($ie80&9kz!dj4)ch70jif$ley=zlr=7ng77'
24+
25+
# SECURITY WARNING: don't run with debug turned on in production!
26+
DEBUG = True
27+
28+
ALLOWED_HOSTS = []
29+
30+
31+
# Application definition
32+
33+
INSTALLED_APPS = [
34+
'django.contrib.admin',
35+
'django.contrib.auth',
36+
'django.contrib.contenttypes',
37+
'django.contrib.sessions',
38+
'django.contrib.messages',
39+
'django.contrib.staticfiles',
40+
'accounts.apps.AccountsConfig',
41+
'files.apps.FilesConfig',
42+
'Homepage.apps.HomepageConfig',
43+
]
44+
45+
MIDDLEWARE = [
46+
'django.middleware.security.SecurityMiddleware',
47+
'django.contrib.sessions.middleware.SessionMiddleware',
48+
'django.middleware.common.CommonMiddleware',
49+
'django.middleware.csrf.CsrfViewMiddleware',
50+
'django.contrib.auth.middleware.AuthenticationMiddleware',
51+
'django.contrib.messages.middleware.MessageMiddleware',
52+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
53+
]
54+
55+
ROOT_URLCONF = 'GEHU_Book_Store.urls'
56+
57+
TEMPLATES = [
58+
{
59+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
60+
'DIRS': ['templates'],
61+
'APP_DIRS': True,
62+
'OPTIONS': {
63+
'context_processors': [
64+
'django.template.context_processors.debug',
65+
'django.template.context_processors.request',
66+
'django.contrib.auth.context_processors.auth',
67+
'django.contrib.messages.context_processors.messages',
68+
],
69+
},
70+
},
71+
]
72+
73+
WSGI_APPLICATION = 'GEHU_Book_Store.wsgi.application'
74+
75+
76+
# Database
77+
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
78+
79+
# DATABASES = {
80+
# 'default': {
81+
# 'ENGINE': 'django.db.backends.sqlite3',
82+
# 'NAME': BASE_DIR / 'db.sqlite3',
83+
# }
84+
# }
85+
86+
DATABASES = {
87+
'default':dj_database_url.parse(os.environ.get("DATABASE_URL"))
88+
}
89+
90+
91+
# Password validation
92+
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
93+
94+
AUTH_PASSWORD_VALIDATORS = [
95+
{
96+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
97+
},
98+
{
99+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
100+
},
101+
{
102+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
103+
},
104+
{
105+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
106+
},
107+
]
108+
109+
110+
# Internationalization
111+
# https://docs.djangoproject.com/en/4.1/topics/i18n/
112+
113+
LANGUAGE_CODE = 'en-us'
114+
115+
TIME_ZONE = 'UTC'
116+
117+
USE_I18N = True
118+
119+
USE_TZ = True
120+
121+
122+
# Static files (CSS, JavaScript, Images)
123+
# https://docs.djangoproject.com/en/4.1/howto/static-files/
124+
125+
STATIC_URL = 'static/'
126+
MEDIA_URL='media/'
127+
MEDIA_ROOT=os.path.join(BASE_DIR,'media')
128+
129+
# Default primary key field type
130+
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
131+
132+
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
133+
134+
STATICFILES_DIRS=[
135+
BASE_DIR,"static"
136+
]

GEHU_Book_Store/urls.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""GEHU_Book_Store URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/4.1/topics/http/urls/
5+
Examples:
6+
Function views
7+
1. Add an import: from my_app import views
8+
2. Add a URL to urlpatterns: path('', views.home, name='home')
9+
Class-based views
10+
1. Add an import: from other_app.views import Home
11+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12+
Including another URLconf
13+
1. Import the include() function: from django.urls import include, path
14+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15+
"""
16+
from django.contrib import admin
17+
from django.urls import path,include
18+
from files.views import *
19+
from accounts.views import *
20+
from Homepage.views import *
21+
from django.conf import settings
22+
from django.conf.urls.static import static
23+
24+
25+
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
26+
urlpatterns = [
27+
path('admin/', admin.site.urls),
28+
path('', include('Homepage.urls')),
29+
path('files_/', include('files.urls')),
30+
path('accounts/', include('accounts.urls')),
31+
32+
]+static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
33+
34+
35+
urlpatterns+= staticfiles_urlpatterns()

GEHU_Book_Store/wsgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for GEHU_Book_Store project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'GEHU_Book_Store.settings')
15+
16+
application = get_wsgi_application()

Homepage/__init__.py

Whitespace-only changes.
169 Bytes
Binary file not shown.
224 Bytes
Binary file not shown.
544 Bytes
Binary file not shown.
221 Bytes
Binary file not shown.
465 Bytes
Binary file not shown.
443 Bytes
Binary file not shown.

Homepage/admin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

Homepage/apps.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class HomepageConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'Homepage'

Homepage/migrations/__init__.py

Whitespace-only changes.
Binary file not shown.

Homepage/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.db import models
2+
3+
# Create your models here.

Homepage/tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

Homepage/urls.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from django.contrib import admin
2+
from django.urls import path,include
3+
from .import views
4+
urlpatterns = [
5+
6+
path('',views.homepage, name='home'),
7+
8+
]

Homepage/views.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.shortcuts import render,HttpResponse
2+
# Create your views here.
3+
4+
def homepage(request):
5+
return render(request,"Home/index.html")

accounts/__init__.py

Whitespace-only changes.
169 Bytes
Binary file not shown.
383 Bytes
Binary file not shown.
544 Bytes
Binary file not shown.
725 Bytes
Binary file not shown.
740 Bytes
Binary file not shown.
2.63 KB
Binary file not shown.

accounts/admin.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.contrib import admin
2+
from .models import UserRegistration
3+
# Register your models here.
4+
admin.site.register(UserRegistration)
5+
# admin.site.register()

accounts/apps.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class AccountsConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'accounts'

accounts/migrations/0001_initial.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 4.1.7 on 2023-07-10 02:46
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
initial = True
9+
10+
dependencies = [
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='UserRegistration',
16+
fields=[
17+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18+
('username', models.CharField(max_length=100)),
19+
('email', models.EmailField(max_length=50)),
20+
('password', models.CharField(max_length=128)),
21+
],
22+
),
23+
]

accounts/migrations/__init__.py

Whitespace-only changes.
Binary file not shown.
Binary file not shown.

accounts/models.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from django.db import models
2+
3+
# Create your models here.
4+
5+
class UserRegistration(models.Model):
6+
username = models.CharField( max_length=100)
7+
email = models.EmailField( max_length=50)
8+
password = models.CharField(max_length=128)
9+

accounts/tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

accounts/urls.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from django.contrib import admin
2+
from django.urls import path,include
3+
from .import views
4+
urlpatterns = [
5+
6+
path('loginin/',views.login_, name='login'),
7+
path("login_user/",views.login_user,name="login_user"),
8+
path("logout_user/",views.logout_user,name="logout_user"),
9+
path("signup_user/",views.signup_user,name="signup_user")
10+
]

accounts/views.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from django.shortcuts import render, redirect
2+
from django.contrib.auth.models import User
3+
from django.contrib import messages
4+
from django.http import HttpResponse
5+
from django.contrib.auth import authenticate
6+
7+
8+
9+
10+
def login_(request):
11+
return render(request,"accounts/index-sign-in-up_.html")
12+
13+
14+
from django.contrib.auth import authenticate, login ,logout
15+
16+
17+
def logout_user(request):
18+
logout(request)
19+
return redirect('home')
20+
21+
def login_user(request):
22+
if request.method == 'POST':
23+
username1 = request.POST.get('username1')
24+
password1 = request.POST.get('password1')
25+
26+
user = authenticate(request, username=username1, password=password1)
27+
28+
if user is not None:
29+
login(request, user) # Log in the user using the login function
30+
return redirect("home")
31+
else:
32+
return HttpResponse("Invalid Crediential")
33+
else:
34+
return HttpResponse("Not Found - 404")
35+
36+
37+
def signup_user(request):
38+
if request.method=='POST':
39+
username=request.POST.get('username')
40+
password = request.POST.get('password')
41+
email = request.POST.get('email')
42+
if User.objects.filter(username=username).exists():
43+
return HttpResponse("Username already exists. Please choose a different username.")
44+
# errors:=
45+
myuser=User.objects.create_user(username,email,password)
46+
# myuser.first_name=username
47+
# d={"name":username}
48+
myuser.save()
49+
return render(request,"accounts/index-sign-in-up_.html")
50+
else:
51+
return HttpResponse("Not Found - 404")

db.sqlite3

140 KB
Binary file not shown.

files/__init__.py

Whitespace-only changes.
166 Bytes
Binary file not shown.
368 Bytes
Binary file not shown.
535 Bytes
Binary file not shown.
1.09 KB
Binary file not shown.
746 Bytes
Binary file not shown.
2.46 KB
Binary file not shown.

files/admin.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.contrib import admin
2+
from .models import Notes
3+
# Register your models here.
4+
admin.site.register(Notes)
5+
# admin.site.register()

files/apps.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class FilesConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'files'

0 commit comments

Comments
 (0)