diff --git a/Myproject/__init__.py b/Myproject/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Myproject/__pycache__/__init__.cpython-310.pyc b/Myproject/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..95db8ac Binary files /dev/null and b/Myproject/__pycache__/__init__.cpython-310.pyc differ diff --git a/Myproject/__pycache__/settings.cpython-310.pyc b/Myproject/__pycache__/settings.cpython-310.pyc new file mode 100644 index 0000000..cbac534 Binary files /dev/null and b/Myproject/__pycache__/settings.cpython-310.pyc differ diff --git a/Myproject/__pycache__/urls.cpython-310.pyc b/Myproject/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000..dc6cb03 Binary files /dev/null and b/Myproject/__pycache__/urls.cpython-310.pyc differ diff --git a/Myproject/__pycache__/wsgi.cpython-310.pyc b/Myproject/__pycache__/wsgi.cpython-310.pyc new file mode 100644 index 0000000..35e3ad1 Binary files /dev/null and b/Myproject/__pycache__/wsgi.cpython-310.pyc differ diff --git a/Myproject/asgi.py b/Myproject/asgi.py new file mode 100644 index 0000000..472ebab --- /dev/null +++ b/Myproject/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for Myproject 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.0/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Myproject.settings') + +application = get_asgi_application() diff --git a/Myproject/settings.py b/Myproject/settings.py new file mode 100644 index 0000000..dbf5d22 --- /dev/null +++ b/Myproject/settings.py @@ -0,0 +1,126 @@ +""" +Django settings for Myproject project. + +Generated by 'django-admin startproject' using Django 4.0.1. + +For more information on this file, see +https://docs.djangoproject.com/en/4.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/4.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/4.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-f2e2!rsiw!6!4lx3)w(xpplg3o$vall@kegvqxbs=zzcjn9klj' + +# 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', + 'website', + 'meetings', + +] + +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 = 'Myproject.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'Myproject.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/4.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/4.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/4.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/4.0/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/Myproject/urls.py b/Myproject/urls.py new file mode 100644 index 0000000..5c2bbbb --- /dev/null +++ b/Myproject/urls.py @@ -0,0 +1,30 @@ +"""Myproject URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/4.0/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path,include +from website.views import welcome,date,about + + + +urlpatterns = [ + path('admin/', admin.site.urls), + path('',welcome,name='home'), + path('date',date), + path('about',about), + path('meetings/',include('meetings.urls')), + + +] diff --git a/Myproject/wsgi.py b/Myproject/wsgi.py new file mode 100644 index 0000000..11c9fe4 --- /dev/null +++ b/Myproject/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for Myproject 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/4.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Myproject.settings') + +application = get_wsgi_application() diff --git a/README.md b/README.md deleted file mode 100644 index 54da6dd..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -# PythonDjango \ No newline at end of file diff --git a/api_basic/__init__.py b/api_basic/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/api_basic/admin.py b/api_basic/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/api_basic/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/api_basic/apps.py b/api_basic/apps.py new file mode 100644 index 0000000..38142fd --- /dev/null +++ b/api_basic/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ApiBasicConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'api_basic' diff --git a/api_basic/migrations/__init__.py b/api_basic/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/api_basic/models.py b/api_basic/models.py new file mode 100644 index 0000000..d494fd3 --- /dev/null +++ b/api_basic/models.py @@ -0,0 +1,8 @@ +from django.db import models + +# Create your models here. +class Article(models.Model): + title=models.charField(max_length=100) + author= models.charField(max_length=100) + email= models.EmailField(max_length=100) + date=models.DateTimeField(auto_now_add=True) \ No newline at end of file diff --git a/api_basic/tests.py b/api_basic/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/api_basic/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/api_basic/views.py b/api_basic/views.py new file mode 100644 index 0000000..39ab918 --- /dev/null +++ b/api_basic/views.py @@ -0,0 +1,3 @@ + +# Create your views here. + diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index eb08901..0000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,58 +0,0 @@ -# Python Django -# Test a Django project on multiple versions of Python. -# Add steps that analyze code, save build artifacts, deploy, and more: -# https://docs.microsoft.com/azure/devops/pipelines/languages/python - -trigger: -- main - -pool: - vmImage: ubuntu-latest -strategy: - matrix: - Python35: - PYTHON_VERSION: '3.5' - Python36: - PYTHON_VERSION: '3.6' - Python37: - PYTHON_VERSION: '3.7' - maxParallel: 3 - -steps: -- task: UsePythonVersion@0 - inputs: - versionSpec: '$(PYTHON_VERSION)' - architecture: 'x64' - -- task: PythonScript@0 - displayName: 'Export project path' - inputs: - scriptSource: 'inline' - script: | - """Search all subdirectories for `manage.py`.""" - from glob import iglob - from os import path - # Python >= 3.5 - manage_py = next(iglob(path.join('**', 'manage.py'), recursive=True), None) - if not manage_py: - raise SystemExit('Could not find a Django project') - project_location = path.dirname(path.abspath(manage_py)) - print('Found Django project in', project_location) - print('##vso[task.setvariable variable=projectRoot]{}'.format(project_location)) - -- script: | - python -m pip install --upgrade pip setuptools wheel - pip install -r requirements.txt - pip install unittest-xml-reporting - displayName: 'Install prerequisites' - -- script: | - pushd '$(projectRoot)' - python manage.py test --testrunner xmlrunner.extra.djangotestrunner.XMLTestRunner --no-input - displayName: 'Run tests' - -- task: PublishTestResults@2 - inputs: - testResultsFiles: "**/TEST-*.xml" - testRunTitle: 'Python $(PYTHON_VERSION)' - condition: succeededOrFailed() diff --git a/db.sqlite3 b/db.sqlite3 new file mode 100644 index 0000000..0fae991 Binary files /dev/null and b/db.sqlite3 differ diff --git a/manage.py b/manage.py new file mode 100644 index 0000000..63068a4 --- /dev/null +++ b/manage.py @@ -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', 'Myproject.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() diff --git a/meetings/__init__.py b/meetings/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/meetings/__pycache__/__init__.cpython-310.pyc b/meetings/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..6120b13 Binary files /dev/null and b/meetings/__pycache__/__init__.cpython-310.pyc differ diff --git a/meetings/__pycache__/admin.cpython-310.pyc b/meetings/__pycache__/admin.cpython-310.pyc new file mode 100644 index 0000000..72477b4 Binary files /dev/null and b/meetings/__pycache__/admin.cpython-310.pyc differ diff --git a/meetings/__pycache__/models.cpython-310.pyc b/meetings/__pycache__/models.cpython-310.pyc new file mode 100644 index 0000000..93af43b Binary files /dev/null and b/meetings/__pycache__/models.cpython-310.pyc differ diff --git a/meetings/__pycache__/urls.cpython-310.pyc b/meetings/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000..1248b22 Binary files /dev/null and b/meetings/__pycache__/urls.cpython-310.pyc differ diff --git a/meetings/__pycache__/views.cpython-310.pyc b/meetings/__pycache__/views.cpython-310.pyc new file mode 100644 index 0000000..f101edb Binary files /dev/null and b/meetings/__pycache__/views.cpython-310.pyc differ diff --git a/meetings/admin.py b/meetings/admin.py new file mode 100644 index 0000000..64fcdc4 --- /dev/null +++ b/meetings/admin.py @@ -0,0 +1,12 @@ +from django.contrib import admin + +from .models import Meeting,Room + +# Register your models here. + + +admin.site.register(Meeting) +admin.site.register(Room) + + + diff --git a/meetings/migrations/0001_initial.py b/meetings/migrations/0001_initial.py new file mode 100644 index 0000000..2bcf806 --- /dev/null +++ b/meetings/migrations/0001_initial.py @@ -0,0 +1,36 @@ +# Generated by Django 4.0.1 on 2022-01-25 13:16 + +import datetime +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Room', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100)), + ('floor_number', models.IntegerField()), + ('room_number', models.IntegerField()), + ], + ), + migrations.CreateModel( + name='Meeting', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=200)), + ('date', models.DateField()), + ('start_time', models.TimeField(default=datetime.time(9, 0))), + ('duration', models.IntegerField(default=1)), + ('room', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='meetings.room')), + ], + ), + ] diff --git a/meetings/migrations/__init__.py b/meetings/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/meetings/migrations/__pycache__/0001_initial.cpython-310.pyc b/meetings/migrations/__pycache__/0001_initial.cpython-310.pyc new file mode 100644 index 0000000..618be0e Binary files /dev/null and b/meetings/migrations/__pycache__/0001_initial.cpython-310.pyc differ diff --git a/meetings/migrations/__pycache__/__init__.cpython-310.pyc b/meetings/migrations/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..936acda Binary files /dev/null and b/meetings/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/meetings/models.py b/meetings/models.py new file mode 100644 index 0000000..b86ab99 --- /dev/null +++ b/meetings/models.py @@ -0,0 +1,26 @@ +from django.db import models +from datetime import time +# Create your models here. + + + +class Room(models.Model): + name=models.CharField(max_length=100) + floor_number=models.IntegerField() + room_number=models.IntegerField() + + def __str__(self): + return f"{self.name} in {self.floor_number} in {self.room_number}" + + + +class Meeting(models.Model): + title=models.CharField(max_length=200) + date= models.DateField() + start_time=models.TimeField(default=time(9)) + duration=models.IntegerField(default=1) + room= models.ForeignKey(Room,on_delete=models.CASCADE) + + def __str__(self): + return f"{self.title} at {self.start_time} on {self.date}" + diff --git a/meetings/templates/meetings/detail.html b/meetings/templates/meetings/detail.html new file mode 100644 index 0000000..18cf369 --- /dev/null +++ b/meetings/templates/meetings/detail.html @@ -0,0 +1,13 @@ +{% extends "base.html" %} + +{% block title %}Meeting:{{meeting.title}} {% endblock %} + +{% block content %} +

{{meeting.title}}


+

Meeting scheduled on:{{meeting.date}}


+

Meeting start time:{{meeting.start_time}}

+ + +home + +{% endblock %} \ No newline at end of file diff --git a/meetings/templates/meetings/new.html b/meetings/templates/meetings/new.html new file mode 100644 index 0000000..5e5e2ab --- /dev/null +++ b/meetings/templates/meetings/new.html @@ -0,0 +1,18 @@ +{% extends "base.html" %} + + +{% block title %}New Meeting {% endblock %} + +{% block content %} +

Plan a new Meeting

+ +
+ + {{form}} +
+ {% csrf_token %} + + +
+ +{% endblock %} \ No newline at end of file diff --git a/meetings/templates/meetings/roompage.html b/meetings/templates/meetings/roompage.html new file mode 100644 index 0000000..cf16d17 --- /dev/null +++ b/meetings/templates/meetings/roompage.html @@ -0,0 +1,30 @@ +{% extends "base.html" %} +{% block title %}Rooms {% endblock %} + +{% block content %} + +

Welcome to the rooms page

+ +

this is a demo paragraph to test weather this is working

+ +

{{message}}

+ +

{{message1}}

+ +

Room Details

+ + + + + +home + + +{% endblock %} \ No newline at end of file diff --git a/meetings/urls.py b/meetings/urls.py new file mode 100644 index 0000000..b423275 --- /dev/null +++ b/meetings/urls.py @@ -0,0 +1,13 @@ +from django.urls import path + +from website import views + +from . import views + +urlpatterns=[ + path('', views.detail,name='detail'), + path('rooms',views.roomview,name='rooms'), + path('new',views.new,name='welcome') + + +] \ No newline at end of file diff --git a/meetings/views.py b/meetings/views.py new file mode 100644 index 0000000..1aafa50 --- /dev/null +++ b/meetings/views.py @@ -0,0 +1,36 @@ +from django.shortcuts import render ,get_object_or_404,redirect +from .models import Meeting +# Create your views here. +from meetings.models import Meeting,Room +from django.forms import modelform_factory +from website.views import welcome + +def detail(request,id): + meeting=get_object_or_404(Meeting,pk=id) + return render(request,"meetings/detail.html",{"meeting":meeting}) + +def roomview(request): + return render(request,"meetings/roompage.html", + {"message":"This page shows the room details", + "rooms":Room.objects.all(), + + + }) + +MeetingForm=modelform_factory(Meeting,exclude=[]) +def new(request): + if(request.method=="POST"): + form= MeetingForm(request.POST) + if form.is_valid(): + form.save() + return redirect("home") + + else: + form= MeetingForm() + return render(request,"meetings/new.html",{"form":form}) + + + + + + diff --git a/website/__init__.py b/website/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/website/__pycache__/__init__.cpython-310.pyc b/website/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..df2f07f Binary files /dev/null and b/website/__pycache__/__init__.cpython-310.pyc differ diff --git a/website/__pycache__/admin.cpython-310.pyc b/website/__pycache__/admin.cpython-310.pyc new file mode 100644 index 0000000..95fd887 Binary files /dev/null and b/website/__pycache__/admin.cpython-310.pyc differ diff --git a/website/__pycache__/apps.cpython-310.pyc b/website/__pycache__/apps.cpython-310.pyc new file mode 100644 index 0000000..7fd0a8e Binary files /dev/null and b/website/__pycache__/apps.cpython-310.pyc differ diff --git a/website/__pycache__/models.cpython-310.pyc b/website/__pycache__/models.cpython-310.pyc new file mode 100644 index 0000000..382ee44 Binary files /dev/null and b/website/__pycache__/models.cpython-310.pyc differ diff --git a/website/__pycache__/views.cpython-310.pyc b/website/__pycache__/views.cpython-310.pyc new file mode 100644 index 0000000..a61fc9f Binary files /dev/null and b/website/__pycache__/views.cpython-310.pyc differ diff --git a/website/admin.py b/website/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/website/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/website/apps.py b/website/apps.py new file mode 100644 index 0000000..2b099b1 --- /dev/null +++ b/website/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class WebsiteConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'website' diff --git a/website/migrations/__init__.py b/website/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/website/migrations/__pycache__/__init__.cpython-310.pyc b/website/migrations/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..ff1a416 Binary files /dev/null and b/website/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/website/models.py b/website/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/website/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/website/static/website/style.css b/website/static/website/style.css new file mode 100644 index 0000000..2252ae9 --- /dev/null +++ b/website/static/website/style.css @@ -0,0 +1,5 @@ +body{ +font-family: sans-serif; +color: cornflowerblue; +background-color: floralwhite: +} \ No newline at end of file diff --git a/website/templates/base.html b/website/templates/base.html new file mode 100644 index 0000000..8f1b774 --- /dev/null +++ b/website/templates/base.html @@ -0,0 +1,22 @@ +{% load static %} + + + + + {% block title %}{% endblock %} + + + + + + +{% block content %} +{% endblock %} + + + + + + + + \ No newline at end of file diff --git a/website/templates/website/welcome.html b/website/templates/website/welcome.html new file mode 100644 index 0000000..743e45c --- /dev/null +++ b/website/templates/website/welcome.html @@ -0,0 +1,30 @@ +{% extends "base.html" %} +{% block title %} Welcome {% endblock %} +{% block content %} + +

Welcome to the Welcome page

+ +

this is a demo paragraph to test weather this is working

+ +

{{message}}

+ +

{{message1}}

+ +

Meetings

+ + + +roomslist + +{% endblock %} \ No newline at end of file diff --git a/website/tests.py b/website/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/website/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/website/views.py b/website/views.py new file mode 100644 index 0000000..cec9c99 --- /dev/null +++ b/website/views.py @@ -0,0 +1,20 @@ +from django.shortcuts import render +from django.http import HttpResponse +# Create your views here. +from datetime import datetime + +from meetings.models import Meeting,Room + +def welcome(request): + return render(request,"website/welcome.html", + {"message":"This is a demo dynamic message", + "message1":"This is a templete example", + "meetings":Meeting.objects.all(), + }) + + +def date(request): + return HttpResponse("this page was served at" +str(datetime.now())) + +def about(request): + return HttpResponse("I am Ashwin working at accenture as a fresher") \ No newline at end of file