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

application = get_asgi_application()
118 changes: 118 additions & 0 deletions CarRental/CarRental/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
"""
Django settings for CarRental project.

Generated by 'django-admin startproject' using Django 6.0.3.

For more information on this file, see
https://docs.djangoproject.com/en/6.0/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/6.0/ref/settings/
"""

from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-6jzo!jq6_ypy)r3b#4a(8d31d@du5bwf-j2d#vuuyytzr7qh^%'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'main',
]

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 = 'CarRental.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 = 'CarRental.wsgi.application'


# Database
# https://docs.djangoproject.com/en/6.0/ref/settings/#databases

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


# Password validation
# https://docs.djangoproject.com/en/6.0/ref/settings/#auth-password-validators

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


# Internationalization
# https://docs.djangoproject.com/en/6.0/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/6.0/howto/static-files/

STATIC_URL = 'static/'
7 changes: 7 additions & 0 deletions CarRental/CarRental/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('main.urls')),
]
16 changes: 16 additions & 0 deletions CarRental/CarRental/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for CarRental project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/6.0/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

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

application = get_wsgi_application()
Empty file added CarRental/main/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions CarRental/main/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions CarRental/main/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class MainConfig(AppConfig):
name = 'main'
Empty file.
3 changes: 3 additions & 0 deletions CarRental/main/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
48 changes: 48 additions & 0 deletions CarRental/main/templates/main/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html>
<head>
<title>About</title>

<style>
body {
font-family: Arial;
background-color: #eef2f7;
text-align: center;
padding: 50px;
}

h1 {
color: #34495e;
}

p {
font-size: 18px;
max-width: 600px;
margin: auto;
}

a {
display: inline-block;
margin-top: 20px;
padding: 10px 20px;
background-color: #3498db;
color: white;
text-decoration: none;
border-radius: 5px;
}

a:hover {
background-color: #0a4a74;
}
</style>

</head>
<body>

<h1>About Car Rentals</h1>
<p>We provide reliable and affordable car rental services, offering a wide range of vehicles to meet your needs and make your journey comfortable and convenient.</p>

<a href="/">Back Home</a>

</body>
</html>
47 changes: 47 additions & 0 deletions CarRental/main/templates/main/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html>
<head>
<title>Home</title>

<style>
body {
font-family: Arial;
background-color: #f5f7fa;
text-align: center;
padding: 50px;
}

h1 {
color: #2c3e50;
}

p {
font-size: 18px;
}

a {
display: inline-block;
margin: 10px;
padding: 10px 20px;
background-color: #3498db;
color: white;
text-decoration: none;
border-radius: 5px;
}

a:hover {
background-color: #0a4a74;
}
</style>

</head>
<body>

<h1>Cars Rentals</h1>
<p>Hello World, This is my new HOME for Car Rentals Website! we're excited to welcome you here.</p>

<a href="/about/">About</a>
<a href="/password/generate/">Generate Password</a>

</body>
</html>
48 changes: 48 additions & 0 deletions CarRental/main/templates/main/password.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html>
<head>
<title>Password</title>

<style>
body {
font-family: Arial;
background-color: #fdf6f0;
text-align: center;
padding: 50px;
}

h1 {
color: #e67e22;
}

h2 {
font-size: 30px;
color: #2c3e50;
margin: 20px 0;
}

a {
display: inline-block;
margin-top: 20px;
padding: 10px 20px;
background-color: #e67e22;
color: white;
text-decoration: none;
border-radius: 5px;
}

a:hover {
background-color: #d35400;
}
</style>

</head>
<body>

<h1>Your Generated Password</h1>
<h2>{{ password }}</h2>

<a href="/">Back Home</a>

</body>
</html>
3 changes: 3 additions & 0 deletions CarRental/main/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.
8 changes: 8 additions & 0 deletions CarRental/main/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.urls import path
from . import views

urlpatterns = [
path('', views.home),
path('about/', views.about),
path('password/generate/', views.generate_password),
]
17 changes: 17 additions & 0 deletions CarRental/main/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django.shortcuts import render
import random

def home(request):
return render(request, 'main/home.html')

def about(request):
return render(request, 'main/about.html')

def generate_password(request):
chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%"

password = ""
for i in range(10):
password += random.choice(chars)

return render(request, 'main/password.html', {'password': password})
22 changes: 22 additions & 0 deletions CarRental/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'CarRental.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()