# HG changeset patch # User Todd Larsen # Date 1222703202 0 # Node ID e076aee6e90f47e1fa65b0d6f26197d8c636f4c2 # Parent 8ecc2e4198cda7521ce626e9f5557980c52a7d47 Take advantage of the Model inheritance provided by polymodel.PolyModel to have Club, School, Sponsor, and Organization actually inherit from the Group Model class, rather than being composed via ReferenceProperties. Patch by: Todd Larsen Review by: Pawel Solyga, Sverre Rabbelier, Augie Fackler Review URL: http://codereviews.googleopensourceprograms.com/606 diff -r 8ecc2e4198cd -r e076aee6e90f app/soc/models/club.py --- a/app/soc/models/club.py Mon Sep 29 15:34:40 2008 +0000 +++ b/app/soc/models/club.py Mon Sep 29 15:46:42 2008 +0000 @@ -27,7 +27,7 @@ import soc.models.group -class Club(base.ModelWithFieldAttributes): +class Club(soc.models.group.Group): """Details specific to a Club. A Club is a generic type of Group that gathers Members into a community. @@ -39,9 +39,5 @@ relation is implemented as the 'members' back-reference Query of the Member model 'club' reference. """ + pass - #: Required 1:1 relationship that ties Club details to the more generic - #: Group details. The back-reference in the Group model is a Query - #: named 'club'. - group = db.ReferenceProperty(reference_class=soc.models.org.Group, - required=True, collection_name="club") diff -r 8ecc2e4198cd -r e076aee6e90f app/soc/models/group.py --- a/app/soc/models/group.py Mon Sep 29 15:34:40 2008 +0000 +++ b/app/soc/models/group.py Mon Sep 29 15:46:42 2008 +0000 @@ -21,30 +21,18 @@ '"Pawel Solyga" ', ] + from google.appengine.ext import db +import polymodel + from django.utils.translation import ugettext_lazy -from soc.models import base from soc.models import countries import soc.models.user -class Group(base.ModelWithFieldAttributes): +class Group(polymodel.PolyModel): """Common data fields for all groups. - - A Group entity participates in the following relationships - implemented as a db.ReferenceProperty elsewhere in another db.Model: - - school), club), sponsor), org) - a 1:1 relationship with each entity containing a more specific type of - Group. These relationships are represented explicitly in the other - "group" models by a db.ReferenceProperty named 'group'. The - collection_name argument to db.ReferenceProperty should be set to the - singular of the entity model name of the other "group" class. The - above relationship names correspond, respectively to these Models: - School, Club, Sponsor, Organization - The relationships listed here are mutually exclusive. For example, - a Group cannot be both a School and a Club at the same time. """ #: Required field storing name of the group. @@ -126,4 +114,4 @@ phone = db.PhoneNumberProperty( verbose_name=ugettext_lazy('Phone Number')) phone.help_text = ugettext_lazy( - 'include complete international calling number with country code') \ No newline at end of file + 'include complete international calling number with country code') diff -r 8ecc2e4198cd -r e076aee6e90f app/soc/models/organization.py --- a/app/soc/models/organization.py Mon Sep 29 15:34:40 2008 +0000 +++ b/app/soc/models/organization.py Mon Sep 29 15:46:42 2008 +0000 @@ -22,26 +22,19 @@ from google.appengine.ext import db -from soc.models import base from soc import models import soc.models.group -import soc.models.administrator -class Organization(base.ModelWithFieldAttributes): +class Organization(soc.models.group.Group): """Organization details. A Organization entity participates in the following relationships implemented as a db.ReferenceProperty elsewhere in another db.Model: - admins) a many:1 relationship associating Administrators with + reviewers) a many:1 relationship associating Reviewers with a specific Organization. This relation is implemented as the - 'admins' back-reference Query of the Organization model 'org' reference. - + 'reviewers' back-reference Query of the Organization model 'org' + reference. """ + pass - #: A 1:1 relationship associating a Organization with more generic - #: Group details and capabilities. The back-reference in - #: the Group model is a Query named 'org'. - group = db.ReferenceProperty(reference_class=models.group.Group, - required=True, collection_name="org") - diff -r 8ecc2e4198cd -r e076aee6e90f app/soc/models/school.py --- a/app/soc/models/school.py Mon Sep 29 15:34:40 2008 +0000 +++ b/app/soc/models/school.py Mon Sep 29 15:46:42 2008 +0000 @@ -27,7 +27,7 @@ import soc.models.group -class School(base.ModelWithFieldAttributes): +class School(soc.models.group.Group): """Details specific to a School. A School is a specific type of Group that gathers Students together. @@ -39,9 +39,5 @@ belonging to) a School. This relation is implemented as the 'students' back-reference Query of the Student model 'school' reference. """ + pass - #: Required 1:1 relationship that ties School details to the more - #: generic Group details. The back-reference in the Group model is a - #: Query named 'school'. - group = db.ReferenceProperty(reference_class=soc.models.group.Group, - required=True, collection_name="school") diff -r 8ecc2e4198cd -r e076aee6e90f app/soc/models/sponsor.py --- a/app/soc/models/sponsor.py Mon Sep 29 15:34:40 2008 +0000 +++ b/app/soc/models/sponsor.py Mon Sep 29 15:46:42 2008 +0000 @@ -23,16 +23,10 @@ from google.appengine.ext import db from soc import models -from soc.models import base import soc.models.group -class Sponsor(base.ModelWithFieldAttributes): +class Sponsor(soc.models.group.Group): """Sponsor details.""" + pass - #: A 1:1 relationship associating a Sponsor with more generic - #: Group details and capabilities. The back-reference in - #: the Group model is a Query named 'sponsor'. - group = db.ReferenceProperty(reference_class=models.group.Group, - required=True, collection_name="sponsor") - \ No newline at end of file