Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- from django.db import models
- from django.db.models import Q
- from datetime import datetime
- class Professor(models.Model):
- nome = models.CharField(max_length = 100, unique = True)
- telefone = models.CharField(max_length = 40)
- email = models.EmailField()
- departamento = models.ForeignKey('Departamento')
- cargo = models.ManyToManyField('Cargo')
- curso = models.ManyToManyField('Curso', related_name = 'curso', through = "Matricula")
- data_cadastro_curso = models.DateField(null = True, blank = True)
- def __unicode__(self):
- return self.nome
- class Meta:
- ordering = ['nome']
- verbose_name_plural = u'professores'
- class Curso(models.Model):
- nome = models.CharField(max_length = 100)
- data = models.DateTimeField()
- professor = models.CharField(max_length = 100, null = True, blank = True)
- requisitos = models.ManyToManyField('Curso', blank = True, null = True, related_name = 'requisitos_do_curso')
- def __unicode__(self):
- return u'%s - %s' % (self.nome, self.data)
- class Matricula(models.Model):
- professor = models.ForeignKey(Professor)
- #curso = models.ForeignKey(Curso, limit_choices_to = (Q(data__gte = datetime.now())))
- curso = models.ForeignKey(Curso)
- concluido = models.BooleanField(blank = True, default = False)
- def __unicode__(self):
- return u" %s no curso %s" % (self.professor.nome, self.curso.nome)
- class Meta:
- db_table = "cadastro_professor_curso"
- verbose_name = u"Matrícula"
- class Departamento(models.Model):
- chefe = models.ForeignKey(Professor, related_name = 'chefe_dp')
- nome = models.CharField(max_length = 30)
- obs = models.TextField(blank = True, null = True)
- def __unicode__(self):
- return self.nome
- class Cargo(models.Model):
- nome = models.CharField(max_length = 100)
- def __unicode__(self):
- return self.nome
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement