diff --git a/TV/.idea/workspace.xml b/TV/.idea/workspace.xml new file mode 100644 index 0000000..72fd2a5 --- /dev/null +++ b/TV/.idea/workspace.xml @@ -0,0 +1,431 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1481126154526 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Telecast/.idea/Telecast.iml b/Telecast/.idea/Telecast.iml new file mode 100644 index 0000000..6711606 --- /dev/null +++ b/Telecast/.idea/Telecast.iml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Telecast/.idea/misc.xml b/Telecast/.idea/misc.xml new file mode 100644 index 0000000..5bbe586 --- /dev/null +++ b/Telecast/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Telecast/.idea/modules.xml b/Telecast/.idea/modules.xml new file mode 100644 index 0000000..5a181dc --- /dev/null +++ b/Telecast/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Telecast/.idea/workspace.xml b/Telecast/.idea/workspace.xml new file mode 100644 index 0000000..f82b020 --- /dev/null +++ b/Telecast/.idea/workspace.xml @@ -0,0 +1,468 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1481132870695 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Telecast/TV/__init__.py b/Telecast/TV/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Telecast/TV/__pycache__/__init__.cpython-35.pyc b/Telecast/TV/__pycache__/__init__.cpython-35.pyc new file mode 100644 index 0000000..ef5f896 Binary files /dev/null and b/Telecast/TV/__pycache__/__init__.cpython-35.pyc differ diff --git a/Telecast/TV/__pycache__/admin.cpython-35.pyc b/Telecast/TV/__pycache__/admin.cpython-35.pyc new file mode 100644 index 0000000..1eb0f97 Binary files /dev/null and b/Telecast/TV/__pycache__/admin.cpython-35.pyc differ diff --git a/Telecast/TV/__pycache__/models.cpython-35.pyc b/Telecast/TV/__pycache__/models.cpython-35.pyc new file mode 100644 index 0000000..12d7819 Binary files /dev/null and b/Telecast/TV/__pycache__/models.cpython-35.pyc differ diff --git a/Telecast/TV/__pycache__/urls.cpython-35.pyc b/Telecast/TV/__pycache__/urls.cpython-35.pyc new file mode 100644 index 0000000..125c8c0 Binary files /dev/null and b/Telecast/TV/__pycache__/urls.cpython-35.pyc differ diff --git a/Telecast/TV/__pycache__/views.cpython-35.pyc b/Telecast/TV/__pycache__/views.cpython-35.pyc new file mode 100644 index 0000000..78b0f34 Binary files /dev/null and b/Telecast/TV/__pycache__/views.cpython-35.pyc differ diff --git a/Telecast/TV/admin.py b/Telecast/TV/admin.py new file mode 100644 index 0000000..532c522 --- /dev/null +++ b/Telecast/TV/admin.py @@ -0,0 +1,6 @@ +from django.contrib import admin + +# Register your models here. +from .models import TV + +admin.site.register(TV) diff --git a/Telecast/TV/apps.py b/Telecast/TV/apps.py new file mode 100644 index 0000000..2896f22 --- /dev/null +++ b/Telecast/TV/apps.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +from django.apps import AppConfig + + +class TvConfig(AppConfig): + name = 'TV' diff --git a/Telecast/TV/migrations/0001_initial.py b/Telecast/TV/migrations/0001_initial.py new file mode 100644 index 0000000..b32c9b8 --- /dev/null +++ b/Telecast/TV/migrations/0001_initial.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.3 on 2016-12-07 17:51 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='TV', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=200)), + ('description', models.CharField(max_length=1000)), + ('duration', models.CharField(max_length=10)), + ('date', models.CharField(max_length=10)), + ('advert', models.BooleanField(default=0)), + ], + ), + ] diff --git a/Telecast/TV/migrations/__init__.py b/Telecast/TV/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Telecast/TV/migrations/__pycache__/0001_initial.cpython-35.pyc b/Telecast/TV/migrations/__pycache__/0001_initial.cpython-35.pyc new file mode 100644 index 0000000..8844d96 Binary files /dev/null and b/Telecast/TV/migrations/__pycache__/0001_initial.cpython-35.pyc differ diff --git a/Telecast/TV/migrations/__pycache__/__init__.cpython-35.pyc b/Telecast/TV/migrations/__pycache__/__init__.cpython-35.pyc new file mode 100644 index 0000000..6eaf456 Binary files /dev/null and b/Telecast/TV/migrations/__pycache__/__init__.cpython-35.pyc differ diff --git a/Telecast/TV/models.py b/Telecast/TV/models.py new file mode 100644 index 0000000..785d09e --- /dev/null +++ b/Telecast/TV/models.py @@ -0,0 +1,14 @@ +from __future__ import unicode_literals + +from django.db import models + + +class TV(models.Model): + name = models.CharField(max_length=200) + description = models.CharField(max_length=1000) + duration = models.CharField(max_length=10) + date = models.CharField(max_length=10) + advert = models.BooleanField(default=0) + + def __str__(self): + return self.name diff --git a/Telecast/TV/templates/TV/edit.html b/Telecast/TV/templates/TV/edit.html new file mode 100644 index 0000000..eacbc90 --- /dev/null +++ b/Telecast/TV/templates/TV/edit.html @@ -0,0 +1,15 @@ + + + + + Edit + + +
+ {% csrf_token %} + + +
+ + \ No newline at end of file diff --git a/Telecast/TV/templates/TV/index.html b/Telecast/TV/templates/TV/index.html new file mode 100644 index 0000000..10463fd --- /dev/null +++ b/Telecast/TV/templates/TV/index.html @@ -0,0 +1,29 @@ + + + + + index.html + {% load static %} + + +
Telecasts
+ +{% if tv_list %} + +{% else %} +

No telecasts are available.

+{% endif %} + + + \ No newline at end of file diff --git a/Telecast/TV/tests.py b/Telecast/TV/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/Telecast/TV/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Telecast/TV/urls.py b/Telecast/TV/urls.py new file mode 100644 index 0000000..cd4a682 --- /dev/null +++ b/Telecast/TV/urls.py @@ -0,0 +1,10 @@ +from django.conf.urls import url +from . import views + +app_name = "TV" +urlpatterns = [ + + url(r'^$', views.index, name='index'), + url(r'^(?P[0-9]*)/$', views.edit, name='edit'), + url(r'^(?P[0-9]*)/save/$', views.save, name='save') +] \ No newline at end of file diff --git a/Telecast/TV/views.py b/Telecast/TV/views.py new file mode 100644 index 0000000..ba0bad7 --- /dev/null +++ b/Telecast/TV/views.py @@ -0,0 +1,36 @@ +from django.shortcuts import render, get_object_or_404 +from django.http import HttpResponse, Http404, HttpResponseRedirect +from .models import TV +from django.urls import reverse + + +# Create your views here. + +def index(request): + tv_list = TV.objects.all() + context = {'tv_list': tv_list} + return render(request, 'TV/index.html', context) + + +def edit(request, id): + obj = get_object_or_404(TV, id=id) + return render(request, 'TV/edit.html', {'obj': obj}) + + +def save(request, id): + obj = get_object_or_404(TV, id=id) + try: + obj.description = request.POST['description'] + except KeyError: + return render(request, 'TV/edit.html', {'obj': obj}) + else: + return HttpResponseRedirect(reverse('index.html')) + + +def add(request): + tv = TV(name=request.POST['name'], description=request.POST['description'], + duration=request.POST['duration'], + date=request.POST['date'], + advert=request.POST['advert']) + tv.save() + return HttpResponseRedirect(reverse('TV:index')) diff --git a/Telecast/Telecast/__init__.py b/Telecast/Telecast/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Telecast/Telecast/__pycache__/__init__.cpython-35.pyc b/Telecast/Telecast/__pycache__/__init__.cpython-35.pyc new file mode 100644 index 0000000..00d5878 Binary files /dev/null and b/Telecast/Telecast/__pycache__/__init__.cpython-35.pyc differ diff --git a/Telecast/Telecast/__pycache__/settings.cpython-35.pyc b/Telecast/Telecast/__pycache__/settings.cpython-35.pyc new file mode 100644 index 0000000..9f0991d Binary files /dev/null and b/Telecast/Telecast/__pycache__/settings.cpython-35.pyc differ diff --git a/Telecast/Telecast/__pycache__/urls.cpython-35.pyc b/Telecast/Telecast/__pycache__/urls.cpython-35.pyc new file mode 100644 index 0000000..0cb65d0 Binary files /dev/null and b/Telecast/Telecast/__pycache__/urls.cpython-35.pyc differ diff --git a/Telecast/Telecast/__pycache__/wsgi.cpython-35.pyc b/Telecast/Telecast/__pycache__/wsgi.cpython-35.pyc new file mode 100644 index 0000000..16f1e9f Binary files /dev/null and b/Telecast/Telecast/__pycache__/wsgi.cpython-35.pyc differ diff --git a/Telecast/Telecast/settings.py b/Telecast/Telecast/settings.py new file mode 100644 index 0000000..0981e79 --- /dev/null +++ b/Telecast/Telecast/settings.py @@ -0,0 +1,121 @@ +""" +Django settings for Telecast project. + +Generated by 'django-admin startproject' using Django 1.10.3. + +For more information on this file, see +https://docs.djangoproject.com/en/1.10/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.10/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'ab1*!_k#1fjl&809$7nn@%l3phb62xk55&a$185j*9uj6w7$zd' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'TV', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +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 = 'Telecast.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 = 'Telecast.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.10/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/1.10/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/1.10/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.10/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/Telecast/Telecast/urls.py b/Telecast/Telecast/urls.py new file mode 100644 index 0000000..24cd25f --- /dev/null +++ b/Telecast/Telecast/urls.py @@ -0,0 +1,23 @@ +"""Telecast URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.10/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import url +from django.contrib import admin +from django.conf.urls import url, include + +urlpatterns = [ + url(r'^TV/', include('TV.urls')), + url(r'^admin/', admin.site.urls), +] diff --git a/Telecast/Telecast/wsgi.py b/Telecast/Telecast/wsgi.py new file mode 100644 index 0000000..3dac56a --- /dev/null +++ b/Telecast/Telecast/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for Telecast 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/1.10/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Telecast.settings") + +application = get_wsgi_application() diff --git a/Telecast/db.sqlite3 b/Telecast/db.sqlite3 new file mode 100644 index 0000000..6b4a664 Binary files /dev/null and b/Telecast/db.sqlite3 differ diff --git a/Telecast/manage.py b/Telecast/manage.py new file mode 100755 index 0000000..d79d976 --- /dev/null +++ b/Telecast/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Telecast.settings") + try: + from django.core.management import execute_from_command_line + except ImportError: + # The above import may fail for some other reason. Ensure that the + # issue is really that Django is missing to avoid masking other + # exceptions on Python 2. + try: + import django + except ImportError: + 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?" + ) + raise + execute_from_command_line(sys.argv)