diff options
author | Alvin Li <liweitianux@gmail.com> | 2013-10-30 10:16:21 +0800 |
---|---|---|
committer | Alvin Li <liweitianux@gmail.com> | 2013-10-30 10:16:21 +0800 |
commit | 1e4a9c0565c3d2f52ec205ae7627ebfc84278735 (patch) | |
tree | b26921e2f5fdec3fa7578584d10ba476abbace40 /97suifangqa/apps/recommend | |
parent | 02afd8a32edb13ea7fc2266ac80092ea15c0930c (diff) | |
download | 97dev-1e4a9c0565c3d2f52ec205ae7627ebfc84278735.tar.bz2 |
* moved 'ValueKind' model from 'recommend/models' to 'indicator/models'
* added field 'type' for 'indicator.models.Indicator'
* added field 'kind' for 'indicator.models.IndicatorRecord',
'InnateConfine'
* updated methods for models 'Indicator', 'IndicatorRecord',
'InnateConfine'
* updated views and templates for 'apps/indicator'
* added 'INDICATOR_RECOMMEND_PERIOD' into 'settings.py'
* added 'type' field for 'indicator.models.Indicator' in
'search_indexes.py'
* added a confirm step for 'EditHistoryData' page when delete a record
* removed dir 'backupdata'; 'queries.txt' moved to 'backup' dir
* moved *.json to 'backup' dir
* removed 'apps/managers*.py'
* updated 'indicator/popup/IndexDesc.html'
* created dir 'apps/indicator/obsolete';
* moved 'indicator/forms.py' to dir 'obsolete';
* splitted views related forms.py from 'views.py', and placed in
'obsolete/views_forms.py'
* loadded newest data into database
* cleaned pervious data files in 'backup' dir
* updated 'README.txt'; added a solution to a redis problem
* added field 'type' of 'indicator.models.Indicator';
for filtering search results and only returning 'NORMAL_TYPE'
Diffstat (limited to '97suifangqa/apps/recommend')
-rw-r--r-- | 97suifangqa/apps/recommend/models.py | 48 |
1 files changed, 2 insertions, 46 deletions
diff --git a/97suifangqa/apps/recommend/models.py b/97suifangqa/apps/recommend/models.py index 0c24c67..9fe8b42 100644 --- a/97suifangqa/apps/recommend/models.py +++ b/97suifangqa/apps/recommend/models.py @@ -108,7 +108,7 @@ class ResearchIndicator(models.Model): # {{{ raise ValueError(u"Error: dataType与Indicator不符") return False elif self.dataType == self.SCOPE_TYPE: - if ind_dataType not in [ind_obj.RANGE_TYPE, ind_obj.FLOAT_RANGE_TYPE]: + if ind_dataType not in [ind_obj.RANGE_TYPE, ind_obj.FLOAT_RANGE_TYPE, ind_obj.FLOAT_TYPE]: raise ValueError(u"Error: dataType与Indicator不符") return False elif self.dataType == self.KIND_TYPE: @@ -208,7 +208,7 @@ class ResearchAtom(models.Model): scope_min = models.FloatField(u"范围下限", null=True, blank=True) scope_max = models.FloatField(u"范围上限", null=True, blank=True) # dataType: KIND - kind = models.ForeignKey("ValueKind", + kind = models.ForeignKey("indicator.ValueKind", null=True, blank=True, related_name="research_atoms", verbose_name=u"种类") ## datetime @@ -418,49 +418,6 @@ class ResearchConfig(models.Model): # }}} -class ValueKind(models.Model): # {{{ - """ - 记录系统所有可能使用到的"种类"值 - 并为需要使用"种类"值的地方提供可选范围(e.g.: recommend.ResearchAtom) - 使用统一的符号(symbol)来寻找及匹配 - """ - name = models.CharField(u"名称", max_length=30) - symbol = models.CharField(u"符号", max_length=30, - help_text=u"仅能使用字母、数字和下划线,最长30字符") - description = models.TextField(u"描述", blank=True) - - class Meta: - verbose_name_plural = u"可选种类" - - def __unicode__(self): - return u'< ValueKind: %s (%s) >' % (self.name, self.symbol) - - def save(self, **kwargs): - if self.is_valid(): - super(ValueKind, self).save(**kwargs) - else: - return self - - def is_valid(self): - # check symbol - sym_regex = re.compile(r'^[_0-9a-zA-Z]+$') - if sym_regex.search(self.symbol): - return True - else: - raise ValueError(u"仅能使用字母、数字和下划线,最长30字符") - return False - - def dump(self, **kwargs): - dump_data = { - 'id': self.id, - 'name': self.name, - 'symbol': self.symbol, - 'description': self.description, - } - return dump_data -# }}} - - # admin admin.site.register([ TreatResponse, @@ -468,6 +425,5 @@ admin.site.register([ #ResearchCombination, ResearchAtom, ResearchConfig, - ValueKind, ]) |