diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2015-02-11 18:02:42 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-02-11 18:02:42 +0100 |
commit | ec824db12597389c87184497796e8d0763c80b51 (patch) | |
tree | fb53154ba33dc4e31fe9bb25677e14d1c8418701 /chimere/models.py | |
parent | c70c2c8f4f58436df8d1c694a74c457954bd1070 (diff) | |
download | Chimère-ec824db12597389c87184497796e8d0763c80b51.tar.bz2 Chimère-ec824db12597389c87184497796e8d0763c80b51.zip |
New importer type XML - XSLT. Importer: add relation between category key and categories
* new importer type XML - XSLT
* associated form and UI modification
* add new model ImporterKeyCategories
* associated migration
* associated admin modification
* longer state field for Importers
* associated migration
Diffstat (limited to 'chimere/models.py')
-rw-r--r-- | chimere/models.py | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/chimere/models.py b/chimere/models.py index 3196ae6..5727098 100644 --- a/chimere/models.py +++ b/chimere/models.py @@ -348,10 +348,9 @@ class Importer(models.Model): blank=True, null=True) license = models.CharField(_(u"License"), max_length=100, blank=True, null=True) - categories = SelectMultipleField(SubCategory, + categories = SelectMultipleField(SubCategory, blank=True, null=True, verbose_name=_(u"Associated subcategories")) - state = models.CharField(_(u"State"), max_length=200, - blank=True, null=True) + state = models.TextField(_(u"State"), blank=True, null=True) associate_marker_to_way = models.BooleanField(_(u"Automatically associate "\ u"a marker to a way"), default=False) automatic_update = models.BooleanField(_(u"Automatically updated"), @@ -379,6 +378,31 @@ class Importer(models.Model): def display_categories(self): return u"\n".join([cat.name for cat in self.categories.all()]) + def get_key_category_dict(self): + dct = {} + # if no category provided: all category are considered + q = SubCategory.objects.all() + if self.categories.count(): + q = self.categories.all() + for cat in q.all(): + dct[defaultfilters.slugify(cat.name)] = cat + + for key_cat in self.key_categories.all(): + dct[key_cat.key] = key_cat.category + return dct + +class ImporterKeyCategories(models.Model): + """ + Association between key and categories + """ + importer = models.ForeignKey(Importer, verbose_name=_(u"Importer"), + related_name='key_categories') + category = models.ForeignKey(SubCategory, verbose_name=_(u"Category")) + key = models.CharField(_(u"Import key"), max_length=200) + + class Meta: + verbose_name = _(u"Importer - Key categories") + STATUS = (('S', _(u'Submited')), ('A', _(u'Available')), ('M', _(u'Modified')), |