Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #112 from postatum/103243506_profile_bug
Browse files Browse the repository at this point in the history
Remove not used params in BaseView
  • Loading branch information
jstoiko committed Sep 18, 2015
2 parents 8ebbe07 + 0099d91 commit 070b238
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions nefertari/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,16 @@ def get_collection_es(self):
from nefertari.elasticsearch import ES
return ES(self.Model.__name__).get_collection(**self._query_params)

def fill_null_values(self, model_cls=None):
def fill_null_values(self):
""" Fill missing model fields in JSON with {key: null value}.
Only run for PUT requests.
"""
if model_cls is None:
model_cls = self.Model
if not model_cls:
if not self.Model:
log.info("%s has no model defined" % self.__class__.__name__)
return

empty_values = model_cls.get_null_values()
empty_values = self.Model.get_null_values()
for field, value in empty_values.items():
if field not in self._json_params:
self._json_params[field] = value
Expand All @@ -224,22 +222,20 @@ def set_public_limits(self):
if self._auth_enabled and not getattr(self.request, 'user', None):
wrappers.set_public_limits(self)

def convert_ids2objects(self, model_cls=None):
def convert_ids2objects(self):
""" Convert object IDs from `self._json_params` to objects if needed.
Only IDs that belong to relationship field of `self.Model`
are converted.
"""
if model_cls is None:
model_cls = self.Model
if not model_cls:
if not self.Model:
log.info("%s has no model defined" % self.__class__.__name__)
return

for field in self._json_params.keys():
if not engine.is_relationship_field(field, model_cls):
if not engine.is_relationship_field(field, self.Model):
continue
rel_model_cls = engine.get_relationship_cls(field, model_cls)
rel_model_cls = engine.get_relationship_cls(field, self.Model)
self.id2obj(field, rel_model_cls)

def setup_default_wrappers(self):
Expand Down

0 comments on commit 070b238

Please sign in to comment.