def save_user(user, name, value, app=None): from models import UserParameter if app is None: app = __guess_extension() __is_defined(app, 'U', name) fullname = "%s.%s" % (app, name) try: p = UserParameter.objects.get(user=user, name=fullname) except UserParameter.DoesNotExist: p = UserParameter() p.user = user p.name = fullname f = get_parameter_form('U', name, app) f()._save_parameter(p, name, value)
def save(self): from models import UserParameter from modoboa.lib.formutils import SeparatorField for name, value in self.cleaned_data.items(): if type(self.fields[name]) is SeparatorField: continue fullname = "%s.%s" % (self.app, name.upper()) try: p = UserParameter.objects.get(user=self.user, name=fullname) except UserParameter.DoesNotExist: p = UserParameter() p.user = self.user p.name = fullname self._save_parameter(p, name, value)