Skip to content

Instantly share code, notes, and snippets.

@jamilatta
Created September 8, 2014 19:57
Show Gist options
  • Save jamilatta/37b1f3416ad61abeff1f to your computer and use it in GitHub Desktop.
Save jamilatta/37b1f3416ad61abeff1f to your computer and use it in GitHub Desktop.
Editorial Manager models
#coding: utf-8
from django.db import models
from django.utils.translation import ugettext_lazy as _
from journalmanager.models import Issue
class EditorialBoard(models.Model):
"""
Represents the editorial board for one issue.
"""
issue = models.ForeignKey(Issue)
members = models.ManyToManyField('EditorialMember')
def __unicode__(self):
return "Editorial board of issue: %s" % self.issue
class EditorialMember(models.Model):
"""
Represents members of an editorial board
Required Fields: First Name, Last Name, E-mail.
"""
role = models.ForeignKey('RoleType')
first_name = models.CharField(_('First Name'), max_length=256)
last_name = models.CharField(_('Last Name'), max_length=256)
email = models.EmailField(_('E-mail'))
institution = models.CharField(_('institution'), max_length=256, null=True,
blank=True)
link_cv = models.URLField(_('Link CV'))
city = models.CharField(_('City'), max_length=256, null=True, blank=True)
state = models.CharField(_('State'), max_length=256, null=True, blank=True)
country = models.CharField(_('Country'), max_length=256, null=True, blank=True)
class RoleType(models.Model):
"""
Represents the editor category
"""
role_name = models.CharField(_('Editor Category'), max_length=256)
@jfunez
Copy link

jfunez commented Sep 8, 2014

vou comçar pelo final:

  • linha 44: label _('Editor Category') acho que esta errado, ou pelo menos parece confuso. acho melhor: _('Role Name')
  • linha 44: o nome do campo role_name , trocaria por: name, até porque vai ser um attr do RoleType, então acho menos verbose RoleType.name do que RoleType.role_name
  • No unicode de EditorialMember deveria mostrar aquele string que aparece tudo o que tem para mostrar. tipo o User.get_full_name()
  • linha 34: link_cv deve ser opcional segundo o comentario da linha 24.
  • linha 14: eu trocaria members = models.ManyToManyField('EditorialMember') por uma relação desde o model EditorialMember tipo:
class EditorialMember(models.Model):
    boards = models.ManyToManyField('EditorialBoard')
    ...

assism cada instancia de EditorialMember, tem os dados do membro é seu role, nesse board.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment