[marinemap] push by sfletche - factoring out m2m save from analysis save into feature save on 2011-10-05 22:27 GMT

0 views
Skip to first unread message

mari...@googlecode.com

unread,
Oct 5, 2011, 6:27:53 PM10/5/11
to marinema...@googlegroups.com
Revision: efcd69fe54a6
Author: sfle...@gmail.com
Date: Wed Oct 5 15:29:46 2011
Log: factoring out m2m save from analysis save into feature save
http://code.google.com/p/marinemap/source/detail?r=efcd69fe54a6

Modified:
/lingcod/analysistools/models.py
/lingcod/features/models.py

=======================================
--- /lingcod/analysistools/models.py Wed Oct 5 08:50:01 2011
+++ /lingcod/analysistools/models.py Wed Oct 5 15:29:46 2011
@@ -56,7 +56,7 @@

@classmethod
def input_manytomany_fields(klass):
- return [f for f in klass._meta.manytomany if
f.attname.startswith('input_')]
+ return [f for f in klass._meta.many_to_many if
f.attname.startswith('input_')]

@property
def inputs(self):
@@ -133,18 +133,15 @@
be called after super.save. Since it also needs to be called before
self.run, it needs to be called here in this
save method rather than its previous location in feature views update
and create (after save has completed)
'''
- def save(self, rerun=True, form=None, *args, **kwargs):
+ def save(self, rerun=True, *args, **kwargs):
if rerun:
self.clear_output_fields() # get rid of old outputs
super(Analysis, self).save(*args, **kwargs) # have to save
first so it has a pk
- if form is not None:
- form.save_m2m()
self.run()
super(Analysis, self).save(*args, **kwargs)
else:
super(Analysis, self).save(*args, **kwargs) # have to save
first so it has a pk
- if form is not None:
- form.save_m2m()
+

class Meta:
abstract = True
=======================================
--- /lingcod/features/models.py Wed Oct 5 08:50:01 2011
+++ /lingcod/features/models.py Wed Oct 5 15:29:46 2011
@@ -65,6 +65,8 @@
superfluous here.)
'''
def save(self, rerun=True, form=None, *args, **kwargs):
+ if form is not None:
+ form.save_m2m()
super(Feature, self).save(*args, **kwargs) # Call the "real"
save() method

@models.permalink

Reply all
Reply to author
Forward
0 new messages