Skip to content

Commit 28cec57

Browse files
committedMar 30, 2019
first commit
0 parents  commit 28cec57

27 files changed

+416
-0
lines changed
 

‎ccc/__init__.py

Whitespace-only changes.
114 Bytes
Binary file not shown.
2.34 KB
Binary file not shown.

‎ccc/__pycache__/urls.cpython-36.pyc

958 Bytes
Binary file not shown.

‎ccc/__pycache__/wsgi.cpython-36.pyc

509 Bytes
Binary file not shown.

‎ccc/settings.py

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
"""
2+
Django settings for ccc project.
3+
4+
Generated by 'django-admin startproject' using Django 2.1.7.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/2.1/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/2.1/ref/settings/
11+
"""
12+
13+
import os
14+
15+
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17+
18+
19+
# Quick-start development settings - unsuitable for production
20+
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
21+
22+
# SECURITY WARNING: keep the secret key used in production secret!
23+
SECRET_KEY = 'sqdg9l$)p(*fw$2x5_1@em7op^eix7che%bn!cslv_%$@ipln&'
24+
25+
# SECURITY WARNING: don't run with debug turned on in production!
26+
DEBUG = True
27+
28+
ALLOWED_HOSTS = []
29+
30+
AUTH_USER_MODEL = 'electionnaire.User'
31+
32+
33+
34+
# Application definition
35+
36+
INSTALLED_APPS = [
37+
'electionnaire.apps.ElectionnaireConfig',
38+
'django.contrib.admin',
39+
'django.contrib.auth',
40+
'django.contrib.contenttypes',
41+
'django.contrib.sessions',
42+
'django.contrib.messages',
43+
'django.contrib.staticfiles',
44+
]
45+
46+
MIDDLEWARE = [
47+
'django.middleware.security.SecurityMiddleware',
48+
'django.contrib.sessions.middleware.SessionMiddleware',
49+
'django.middleware.common.CommonMiddleware',
50+
'django.middleware.csrf.CsrfViewMiddleware',
51+
'django.contrib.auth.middleware.AuthenticationMiddleware',
52+
'django.contrib.messages.middleware.MessageMiddleware',
53+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
54+
]
55+
56+
ROOT_URLCONF = 'ccc.urls'
57+
58+
TEMPLATES = [
59+
{
60+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
61+
'DIRS': [],
62+
'APP_DIRS': True,
63+
'OPTIONS': {
64+
'context_processors': [
65+
'django.template.context_processors.debug',
66+
'django.template.context_processors.request',
67+
'django.contrib.auth.context_processors.auth',
68+
'django.contrib.messages.context_processors.messages',
69+
],
70+
},
71+
},
72+
]
73+
74+
WSGI_APPLICATION = 'ccc.wsgi.application'
75+
76+
77+
# Database
78+
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
79+
80+
DATABASES = {
81+
'default': {
82+
'ENGINE': 'django.db.backends.sqlite3',
83+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
84+
}
85+
}
86+
87+
88+
# Password validation
89+
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
90+
91+
AUTH_PASSWORD_VALIDATORS = [
92+
{
93+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
94+
},
95+
{
96+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
97+
},
98+
{
99+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
100+
},
101+
{
102+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
103+
},
104+
]
105+
106+
107+
# Internationalization
108+
# https://docs.djangoproject.com/en/2.1/topics/i18n/
109+
110+
LANGUAGE_CODE = 'en-us'
111+
112+
TIME_ZONE = 'UTC'
113+
114+
USE_I18N = True
115+
116+
USE_L10N = True
117+
118+
USE_TZ = True
119+
120+
121+
# Static files (CSS, JavaScript, Images)
122+
# https://docs.djangoproject.com/en/2.1/howto/static-files/
123+
124+
STATIC_URL = '/static/'
125+
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
126+
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
127+
MEDIA_URL = '/media/'

‎ccc/urls.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""ccc URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/2.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+
19+
urlpatterns = [
20+
path('admin/', admin.site.urls),
21+
path('', include('electionnaire.urls')),
22+
path('ec/', include('electionnaire.urls')),
23+
]

‎ccc/wsgi.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for ccc 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/2.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', 'ccc.settings')
15+
16+
application = get_wsgi_application()

‎db.sqlite3

200 KB
Binary file not shown.

‎electionnaire/__init__.py

Whitespace-only changes.
124 Bytes
Binary file not shown.
484 Bytes
Binary file not shown.
354 Bytes
Binary file not shown.
2.74 KB
Binary file not shown.
253 Bytes
Binary file not shown.
338 Bytes
Binary file not shown.

‎electionnaire/admin.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from django.contrib import admin
2+
from django.contrib.auth.admin import UserAdmin
3+
from .models import Post, Candidate, Constituency, User, Party, Eci, Voter
4+
5+
# Register your models here.
6+
7+
admin.site.register(User, UserAdmin)
8+
admin.site.register(Candidate)
9+
admin.site.register(Constituency)
10+
admin.site.register(Post)
11+
admin.site.register(Party)
12+
admin.site.register(Eci)
13+
admin.site.register(Voter)

‎electionnaire/apps.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class ElectionnaireConfig(AppConfig):
5+
name = 'electionnaire'
+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Generated by Django 2.1.7 on 2019-03-30 12:35
2+
3+
from django.conf import settings
4+
import django.contrib.auth.models
5+
import django.contrib.auth.validators
6+
from django.db import migrations, models
7+
import django.db.models.deletion
8+
import django.utils.timezone
9+
10+
11+
class Migration(migrations.Migration):
12+
13+
initial = True
14+
15+
dependencies = [
16+
('auth', '0009_alter_user_last_name_max_length'),
17+
]
18+
19+
operations = [
20+
migrations.CreateModel(
21+
name='User',
22+
fields=[
23+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
24+
('password', models.CharField(max_length=128, verbose_name='password')),
25+
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
26+
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
27+
('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')),
28+
('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')),
29+
('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
30+
('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
31+
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
32+
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
33+
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
34+
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
35+
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
36+
],
37+
options={
38+
'verbose_name': 'user',
39+
'verbose_name_plural': 'users',
40+
'abstract': False,
41+
},
42+
managers=[
43+
('objects', django.contrib.auth.models.UserManager()),
44+
],
45+
),
46+
migrations.CreateModel(
47+
name='Candidate',
48+
fields=[
49+
('id', models.CharField(max_length=100, primary_key='True', serialize=False)),
50+
('name', models.CharField(max_length=50)),
51+
('photo', models.ImageField(upload_to='candidates')),
52+
],
53+
),
54+
migrations.CreateModel(
55+
name='Constituency',
56+
fields=[
57+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
58+
('name', models.CharField(max_length=50)),
59+
],
60+
),
61+
migrations.CreateModel(
62+
name='Eci',
63+
fields=[
64+
('id', models.CharField(max_length=100, primary_key='True', serialize=False)),
65+
('name', models.CharField(max_length=50)),
66+
('user', models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
67+
],
68+
),
69+
migrations.CreateModel(
70+
name='Party',
71+
fields=[
72+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
73+
('name', models.CharField(max_length=50)),
74+
('symbols', models.ImageField(upload_to='symbols')),
75+
],
76+
),
77+
migrations.CreateModel(
78+
name='Post',
79+
fields=[
80+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
81+
('image', models.ImageField(upload_to='posts')),
82+
('post_time', models.DateTimeField(default=django.utils.timezone.now)),
83+
('caption', models.CharField(max_length=200)),
84+
('severity', models.IntegerField()),
85+
('severity_eci', models.IntegerField()),
86+
],
87+
),
88+
migrations.CreateModel(
89+
name='Voter',
90+
fields=[
91+
('voter_id', models.CharField(max_length=100, primary_key='True', serialize=False)),
92+
('aadhar_no', models.CharField(max_length=50, unique=True)),
93+
('name', models.CharField(max_length=50)),
94+
('phone', models.CharField(max_length=10)),
95+
('email', models.EmailField(max_length=50, unique=True)),
96+
('voted', models.BooleanField(default=True)),
97+
('constituency', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='electionnaire.Constituency')),
98+
('user', models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
99+
],
100+
),
101+
migrations.AddField(
102+
model_name='post',
103+
name='voter',
104+
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='electionnaire.Voter'),
105+
),
106+
migrations.AddField(
107+
model_name='candidate',
108+
name='constituency',
109+
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='electionnaire.Constituency'),
110+
),
111+
migrations.AddField(
112+
model_name='candidate',
113+
name='party',
114+
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='electionnaire.Party'),
115+
),
116+
]

‎electionnaire/migrations/__init__.py

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

‎electionnaire/models.py

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
from django.db import models
2+
from django.contrib.auth.models import AbstractUser
3+
from django.utils import timezone
4+
from django.core.validators import MaxValueValidator, MinValueValidator
5+
6+
# Create your models here.
7+
8+
9+
class User(AbstractUser):
10+
@property
11+
def is_voter(self):
12+
if hasattr(self, 'voter'):
13+
return True
14+
return False
15+
16+
@property
17+
def is_eci(self):
18+
if hasattr(self, 'eci'):
19+
return True
20+
return False
21+
22+
23+
class Party(models.Model):
24+
name = models.CharField(max_length=50)
25+
symbols = models.ImageField(upload_to='symbols')
26+
27+
def __str__(self):
28+
return self.name
29+
30+
31+
class Constituency(models.Model):
32+
name = models.CharField(max_length=50)
33+
34+
def __str__(self):
35+
return self.name
36+
37+
38+
class Candidate(models.Model):
39+
id = models.CharField(primary_key='True', max_length=100)
40+
name = models.CharField(max_length=50)
41+
photo = models.ImageField(upload_to='candidates')
42+
party = models.ForeignKey(Party, on_delete=models.CASCADE)
43+
constituency = models.ForeignKey(Constituency, on_delete=models.CASCADE)
44+
45+
def __str__(self):
46+
return self.name
47+
48+
49+
class Eci(models.Model):
50+
user = models.OneToOneField(User, on_delete=models.CASCADE, null=True)
51+
id = models.CharField(primary_key='True', max_length=100)
52+
name = models.CharField(max_length=50)
53+
54+
def __str__(self):
55+
return self.name
56+
57+
58+
class Voter(models.Model):
59+
user = models.OneToOneField(User, on_delete=models.CASCADE, null=True)
60+
voter_id = models.CharField(primary_key='True', max_length=100)
61+
aadhar_no = models.CharField(max_length=50, unique=True)
62+
name = models.CharField(max_length=50)
63+
phone = models.CharField(max_length=10)
64+
email = models.EmailField(max_length=50, unique=True)
65+
voted = models.BooleanField(default=False)
66+
constituency = models.ForeignKey(Constituency, on_delete=models.CASCADE)
67+
68+
def __str__(self):
69+
return self.name
70+
71+
72+
class Post(models.Model):
73+
image = models.ImageField(upload_to='posts')
74+
voter = models.ForeignKey(Voter, on_delete=models.CASCADE)
75+
post_time = models.DateTimeField(default=timezone.now, blank=False)
76+
caption = models.CharField(max_length=200)
77+
severity = models.IntegerField(
78+
default=1,
79+
validators=[MaxValueValidator(5), MinValueValidator(1)]
80+
)
81+
severity_eci = models.IntegerField(
82+
default=1,
83+
validators=[MaxValueValidator(5), MinValueValidator(1)]
84+
)

‎electionnaire/tests.py

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

‎electionnaire/urls.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.urls import path
2+
from . import views
3+
4+
urlpatterns = [
5+
path('', views.index, name='index'),
6+
]

‎electionnaire/views.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from django.shortcuts import render
2+
from django.http import HttpResponse
3+
4+
# Create your views here.
5+
6+
7+
def index(request):
8+
return HttpResponse("Election boi")

‎manage.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python
2+
import os
3+
import sys
4+
5+
if __name__ == '__main__':
6+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ccc.settings')
7+
try:
8+
from django.core.management import execute_from_command_line
9+
except ImportError as exc:
10+
raise ImportError(
11+
"Couldn't import Django. Are you sure it's installed and "
12+
"available on your PYTHONPATH environment variable? Did you "
13+
"forget to activate a virtual environment?"
14+
) from exc
15+
execute_from_command_line(sys.argv)

0 commit comments

Comments
 (0)
Please sign in to comment.