Created
March 29, 2011 23:53
-
-
Save octaflop/893598 to your computer and use it in GitHub Desktop.
part of the models file for verebena
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the admin views | |
from django.contrib import admin | |
from django.contrib.auth.admin import UserAdmin | |
from verbena.models import Student, Faculty, NewsRelease, Location, Project,\ | |
VolunteerOpportunity, Organization, Workshop, ActionGroup, Grant | |
class StudentAdmin(UserAdmin): | |
list_display = ('studying','comp_year',) | |
class FacultyAdmin(UserAdmin): | |
list_display = ('in_faculty',) | |
class OrganizationAdmin(UserAdmin): | |
list_display = ('name', 'about', 'website',) | |
prepopulated_fields = {'slug': ('name',)} | |
display_inline = ('location', 'workshops',) | |
admin.site.register(Student, StudentAdmin) | |
admin.site.register(Faculty, FacultyAdmin) | |
admin.site.register(Organization, OrganizationAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.contrib.auth.models import User | |
from django.contrib.localflavor.us.models import PhoneNumberField | |
from django.utils.translation import ugettext_lazy as _ | |
#from pinax.apps.profiles.models import Profile | |
from pinax.apps.tribes.models import Tribe | |
import datetime | |
############################################################################# | |
# INDIVIDUAL-based models | |
# Organization -> a non-individual user | |
# Action individual, Student, Faculty (admin is untouched?) -> individual users | |
class Member(User): | |
""" An abstract to represent all signed-in users""" | |
slug = models.SlugField(_("URL-friendly name"), max_length=80) | |
def __unicode__(self): | |
return self.username | |
class Meta: | |
verbose_name = _("Member") | |
verbose_name_plural = _("Members") | |
class GeneralMember(Member): | |
""" An entity representing a registered, unaffiliated user. | |
Individual persons are represented in this way. This ensures that only | |
individuals can sign up for projects and volunteer events. | |
This is also the main model for initial signups. | |
* apply for grants | |
""" | |
how_heard = models.TextField(_("Reference"), | |
help_text=_("How did you hear about us?"), | |
blank=True) | |
class Organization(Member): | |
""" Organizations are entities applying for projects or grants. | |
Organizations share a single login. | |
Organizations may not apply for workshops and participate in volunteer | |
events. | |
""" | |
name = models.CharField(_("Organization name"), | |
help_text=_("The name of your organization"), | |
max_length=100) | |
community = models.CharField( | |
_("What community do you represent or work with?"), | |
max_length=180, | |
blank=True) | |
mandate = models.CharField( | |
_("What is your organization's goal or mandate?"), | |
max_length=180, | |
blank=True) | |
service = models.TextField( | |
_("How does your organization goal or mandate fit in with our\ | |
desire to support community organizations?"), | |
blank=True) | |
funding = models.TextField( | |
_("What are your organization's principal sources of funding?"), | |
blank=True) | |
annual_budget = models.CharField( | |
_("What is your organization's annual budget?"), | |
max_length=25, | |
blank=True) | |
nonprofit_status = models.BooleanField( | |
_("Are you a registered non-profit?"), | |
default=False) | |
about = models.TextField(_("About")) | |
location = models.ForeignKey("Location") | |
website = models.URLField(_("website"), blank=True, null=True) | |
#workshops = models.ManyToManyField("Workshop", | |
# related_name = "organization-workshops", | |
# verbose_name = "organization's workshops", | |
# blank=True, null=True) | |
def __unicode__(self): | |
return self.name | |
@models.permalink | |
def get_absolute_url(self): | |
return ('org_view', [str(self.slug)]) | |
# Call time options for students and faculty | |
CALL_TIMES = ( | |
('MO', 'Morning'), | |
('AF', 'Afternoon'), | |
('EV', 'Evening'), | |
) | |
class Student(GeneralMember): | |
""" | |
A student must be able to: | |
* apply for an ARX project | |
* Request to book a room | |
* Lookup volunteer opportunities | |
* Choose to receive the newsletter | |
""" | |
phone = PhoneNumberField(_("Phone Number"), blank=True, null=True) | |
call_time = models.CharField(_("Best time to call"), | |
help_text=_("Generally, when is the best time to call?"), | |
choices=CALL_TIMES, | |
max_length=2, | |
blank=True, null=True) | |
studying = models.CharField(_("Course of study"), max_length=80, | |
blank=True, null=True) | |
comp_year = models.IntegerField(_("Expected year of completion"), | |
max_length=4, | |
blank=True, null=True) | |
class Meta: | |
verbose_name = _("student") | |
verbose_name_plural = _("students") | |
class Faculty(GeneralMember): | |
""" | |
* Book a presentation | |
* Choose to receive the newsletter | |
They may not apply for grants | |
""" | |
# The faculty the faculty member is in | |
in_faculty = models.CharField(_("Is a member of faculty"), | |
max_length=80, blank=True, null=True) | |
phone = PhoneNumberField(_("Phone Number"), blank=True, null=True) | |
phone_ext = models.CharField(_("Phone extension"), | |
blank=True, | |
max_length=10, null=True) | |
call_time = models.CharField(_("Best time to call"), | |
help_text=_("Generally, when is the best time to call?"), | |
choices=CALL_TIMES, | |
max_length=2, blank=True, null=True) | |
class Meta: | |
verbose_name = _("faculty member") | |
verbose_name_plural = _("faculty members") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment