Commit 62721014 authored by João Denis Rodrigues's avatar João Denis Rodrigues

Modelagem dos dados

parents
# base de dados
*.csv
*.xls
*.xlsx
*.sqlite3
src/cache
*.json
# lixo
*~
*.swp
*.bkp
*.pyc
**/.~c9*
.idea
**/__pycache__
"""
Django settings for adega project.
Generated by 'django-admin startproject' using Django 1.11.3.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/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.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '-sat5n-rxhp#vsz0xzzwis7qqaqqagycxan2c0o)_9(ge^8#i^'
# 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',
'admission.apps.AdmissionConfig',
'course.apps.CourseConfig',
'degree.apps.DegreeConfig',
'klass.apps.KlassConfig',
'student.apps.StudentConfig',
]
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 = 'adega.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 = 'adega.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/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.11/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.11/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.11/howto/static-files/
STATIC_URL = '/static/'
"""adega URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/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
urlpatterns = [
url(r'^admin/', admin.site.urls),
]
"""
WSGI config for adega 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.11/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "adega.settings")
application = get_wsgi_application()
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class AdmissionConfig(AppConfig):
name = 'admission'
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-07-27 14:55
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('degree', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Admission',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('year', models.PositiveIntegerField()),
('semester', models.PositiveIntegerField()),
('degree', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='degree.Degree')),
],
),
]
from django.db import models
from degree.models import Degree
# Create your models here.
class Admission(models.Model):
year = models.PositiveIntegerField()
semester = models.PositiveIntegerField()
degree = models.ForeignKey(Degree)
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class CourseConfig(AppConfig):
name = 'course'
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-07-27 14:55
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Course',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('code', models.CharField(max_length=8)),
('credits', models.IntegerField()),
('workload', models.FloatField()),
],
),
]
from django.db import models
# Create your models here.
class Course(models.Model):
name = models.CharField(max_length = 255)
code = models.CharField(max_length = 8)
credits = models.IntegerField()
workload = models.FloatField() # Carga horaria
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class DegreeConfig(AppConfig):
name = 'degree'
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-07-27 14:55
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('course', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='CourseCurriculum',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('period', models.PositiveIntegerField(null=True)),
('type_course', models.CharField(max_length=255)),
('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='course.Course')),
],
),
migrations.CreateModel(
name='Curriculum',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('start_year', models.IntegerField()),
('current', models.BooleanField()),
('courses', models.ManyToManyField(through='degree.CourseCurriculum', to='course.Course')),
],
),
migrations.CreateModel(
name='Degree',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50)),
('code', models.CharField(max_length=4)),
('report_year', models.PositiveIntegerField(blank=True, null=True)),
('report_semester', models.PositiveIntegerField(blank=True, null=True)),
],
),
migrations.AddField(
model_name='curriculum',
name='degree',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='degree.Degree'),
),
migrations.AddField(
model_name='coursecurriculum',
name='curriculum',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='degree.Curriculum'),
),
]
from django.db import models
from django.db.models import Max
from course.models import Course
# Create your models here.
class Degree(models.Model):
name = models.CharField(max_length = 50)
code = models.CharField(max_length = 4)
report_year = models.PositiveIntegerField(null = True, blank = True)
report_semester = models.PositiveIntegerField(null = True, blank = True)
class Curriculum(models.Model):
degree = models.ForeignKey(Degree)
start_year = models.IntegerField()
courses = models.ManyToManyField(Course, through='CourseCurriculum')
current = models.BooleanField()
def get_amount_of_semesters(self):
max_period = CourseCurriculum.objecs.filter(curriculum = self).aggregate(Max('period'))
return max_period['period__max']
class CourseCurriculum(models.Model):
curriculum = models.ForeignKey(Curriculum)
course = models.ForeignKey(Course)
period = models.PositiveIntegerField(null = True)
type_course = models.CharField(max_length = 255)
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class KlassConfig(AppConfig):
name = 'klass'
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-07-27 14:55
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Klass',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('year', models.PositiveIntegerField()),
('semester', models.PositiveIntegerField()),
('letter', models.CharField(blank=True, max_length=1, null=True)),
],
),
migrations.CreateModel(
name='StudentKlass',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('grade', models.FloatField(blank=True, null=True)),
('situation', models.CharField(max_length=255)),
('klass', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='klass.Klass')),
],
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-07-27 14:55
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('student', '0001_initial'),
('course', '0001_initial'),
('klass', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='studentklass',
name='student',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='student.Student'),
),
migrations.AddField(
model_name='klass',
name='course',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='course.Course'),
),
]
from django.db import models
from course.models import Course
from student.models import Student
# Create your models here.
class Klass(models.Model):
year = models.PositiveIntegerField()
semester = models.PositiveIntegerField()
course = models.ForeignKey(Course)
letter = models.CharField(max_length = 1, null = True, blank = True)
class StudentKlass(models.Model):
grade = models.FloatField(null=True, blank=True)
situation = models.CharField(max_length = 255)
student = models.ForeignKey(Student)
klass = models.ForeignKey(Klass)
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "adega.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)
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class StudentConfig(AppConfig):
name = 'student'
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-07-27 14:55
from __future__ import unicode_literals
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('degree', '0001_initial'),
('klass', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Student',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('ira', models.FloatField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(0)])),
('grr', models.CharField(max_length=15)),
('evasion_form', models.CharField(max_length=255)),
('evasion_year', models.PositiveIntegerField(blank=True, null=True)),
('evasion_semester', models.PositiveIntegerField(blank=True, null=True)),
('current_curriculum', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='degree.Curriculum')),
('klasses', models.ManyToManyField(through='klass.StudentKlass', to='klass.Klass')),
],
),
]
from django.db import models
from django.core.validators import MinValueValidator
from degree.models import Curriculum
# Create your models here.
class Student(models.Model):
name = models.CharField(max_length=255)
ira = models.FloatField(validators = [MinValueValidator(0)], null = True, blank = True)
grr = models.CharField(max_length = 15)
evasion_form = models.CharField(max_length = 255)
evasion_year = models.PositiveIntegerField(null = True, blank = True)
evasion_semester = models.PositiveIntegerField(null = True, blank = True)
current_curriculum = models.ForeignKey(Curriculum)
klasses = models.ManyToManyField('klass.Klass', through = 'klass.StudentKlass')
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment