diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2010-11-15 12:15:08 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2010-11-15 12:15:08 +0100 |
commit | e5107a102db88e5c53195289d773f6c84403a51c (patch) | |
tree | f80887379f7cdfa9d223668a061cda21d20e0759 | |
parent | c908506259810c99f9df75fabfea48d0b7ce4ca8 (diff) | |
download | Chimère-e5107a102db88e5c53195289d773f6c84403a51c.tar.bz2 Chimère-e5107a102db88e5c53195289d773f6c84403a51c.zip |
Simplify ManyToManyField
-rw-r--r-- | chimere/main/models.py | 10 | ||||
-rw-r--r-- | chimere/main/widgets.py | 5 |
2 files changed, 3 insertions, 12 deletions
diff --git a/chimere/main/models.py b/chimere/main/models.py index 3efc1bc..f8f4c80 100644 --- a/chimere/main/models.py +++ b/chimere/main/models.py @@ -27,8 +27,7 @@ from django.contrib.gis.gdal import SpatialReference from django.contrib import admin from chimere import settings -from chimere.main.widgets import PointField, RouteField, \ - ManyToManyField_NoSyncdb +from chimere.main.widgets import PointField, RouteField class News(models.Model): """News of the site @@ -163,8 +162,8 @@ class SubCategory(models.Model): if area_name: area = Area.objects.get(urn=area_name) # if there some restrictions with categories limit them - if area.subcategories.count(): - sub_ids = [sub.id for sub in area.subcategories.all()] + if area.subcategory_set.count(): + sub_ids = [sub.id for sub in area.subcategory_set.all()] # if no area is defined for a category don't filter it sub_ids += [sub.id for sub in subcategories if not sub.areas.count()] @@ -391,9 +390,6 @@ class Area(models.Model, SimpleArea): name = models.CharField(_("Name"), max_length=150) urn = models.SlugField(_("Area urn"), max_length=50, blank=True, unique=True) - subcategories = ManyToManyField_NoSyncdb(SubCategory, - related_name='subcategories', blank=True, null=True, - db_table=u'subcategory_areas') order = models.IntegerField(_("Order")) available = models.BooleanField(_("Available")) upper_left_corner = models.PointField(_("Upper left corner"), diff --git a/chimere/main/widgets.py b/chimere/main/widgets.py index 4ad6475..195414b 100644 --- a/chimere/main/widgets.py +++ b/chimere/main/widgets.py @@ -33,11 +33,6 @@ URL_OSM_CSS = ["http://www.openlayers.org/api/theme/default/style.css"] URL_OSM_JS = ["http://www.openlayers.org/api/OpenLayers.js", "http://www.openstreetmap.org/openlayers/OpenStreetMap.js"] -class ManyToManyField_NoSyncdb(models.ManyToManyField): - def __init__(self, *args, **kwargs): - super(ManyToManyField_NoSyncdb, self).__init__(*args, **kwargs) - self.creates_table = False - def getMapJS(area_name=''): '''Variable initialization for drawing the map ''' |