예제 #1
0
    def save_settings(self,client, params):
        """Handles saving of the settings and gettings the settings view again

        :param Client client: The requesting client
        :param dict params: The form-parameters from the settings view
        :return: dict - Status and html-layout data response
        """
        general_form = GeneralSettingsForm(params, instance=Settings.objects.all()[0])        
        if general_form.is_valid(): 
            general_form.save()
            client_response, tpl_params = self._get_settings(client, params)
            client_response.update({
                'status':{
                    'code':'SETTINGS_UPDATE_OK',
                    'i18n':_('Settings succesfully updated'),
                    'type': HWIOS.ws_realm._t['notify-info']
                }
            })
            notify_others(client, client_response,'/settings/modified/', r'^/settings/$', tpl_params)
            publish_activity(client.profile, _('Settings updated'),'/settings/',[0,0,4,0,0])
        else: 
            client_response.update({'status':{
                'code':'INVALID_FORM',
                'i18n':_('invalid form'),
                'type': HWIOS.ws_realm._t['notify-warning']
                }
            })
        return client_response
예제 #2
0
파일: settings.py 프로젝트: mmetzmac/hwios
 def save_settings(self,client, params):
     general_form = GeneralSettingsForm(params, instance=Settings.objects.all()[0])        
     if general_form.is_valid(): 
         general_form.save()
         client_response, tpl_params = self._get_settings(client, params)
         client_response.update({
             'status':{
                 'code':'SETTINGS_UPDATE_OK',
                 'i18n':_('Settings succesfully updated'),
                 'type': HWIOS.ws_realm._t['notify-info']
             }
         })
         print tpl_params
         notify_others(client, client_response,'/settings/modified/', r'^/settings/$', tpl_params)
         publish_activity(client.profile, _('Settings updated'),'/settings/',[0,0,4,0,0])
     else: 
         client_response.update({'status':{
             'code':'INVALID_FORM',
             'i18n':_('invalid form'),
             'type': HWIOS.ws_realm._t['notify-warning']
             }
         })
     return client_response