Beispiel #1
0
    def __init__(self, user, *args, **kwargs):
        self.user = user
        kwargs['initial'] = {
            'email': self.user.username,
        }
        super(UserSettingsForm, self).__init__(*args, **kwargs)
        
        rest_actions = RestAction()
        actions = rest_actions.get_all()
        
        self.action_old_values = {}
        
        rest_properties = RestProperties(username=self.user.username)
        for i, action in enumerate(actions):
            if action.get('visibility', "") == "global":
                action['options'] = rest_actions.options(action_id=action['actionId'])
                
                result = rest_properties.get(actionId=action['actionId'])
                
                action_value = False
                if 'value' in result and result['value'] == "true":
                    action_value = True
                #if 'errorType' in result and result['errorType'] == "org.backmeup.model.exceptions.UnknownUserPropertyException":
                
                self.action_old_values['actions_value_%s' % i] = action_value
		self.fields['actions_value_%s' % i] = forms.BooleanField(label=_(action['title']), initial=action_value, required=False, help_text=_(action['description']))
                self.fields['actions_key_%s' % i] = forms.CharField(widget=forms.HiddenInput, initial=action['actionId'])
Beispiel #2
0
def verify_email(request, verify_hash=None):
    if request.method == 'POST' or verify_hash:
        data = {
            "verify_hash": verify_hash,
        }
        form = UserEmailVerificationForm(request.POST or data)
        if form.is_valid():
            email = form.cleaned_data['email']
	    messages.add_message(request, messages.INFO, _('user\'s email %(account)s is verified') % {'account':email})
            request.session['validated_email'] = email
	    #Volltext-Indizierung auf true
	    rest_properties = RestProperties(username=email)
	    result_property = rest_properties.post(actionId="org.backmeup.indexer", value="true")
            return redirect('datasource-select')
        #else:
        #    messages.add_message(request, messages.INFO, 'user\'s email couldn\'t be verified')
    else:
        form = UserEmailVerificationForm()
    
    return render_to_response(
        "www/access/verify_email.html",
        {
            "form": form,
        },
        context_instance=RequestContext(request)
    )
Beispiel #3
0
 def save(self):
     rest_api = RestUser(self.user.username)
     data = {}
     
     old_password = self.cleaned_data['old_password']
     new_password = self.cleaned_data.get('new_password1', False)
     new_key_ring = self.cleaned_data.get('new_password1', False)
     new_email = self.cleaned_data.get('email', self.user.username)
     
     data['oldPassword'] = old_password
     data['oldKeyRing'] = old_password
     if new_password:
         data['password'] = new_password
     if new_key_ring:
         data['newKeyRing'] = new_key_ring
     if not new_email == self.user.username:
         data['email'] = new_email
         data['username'] = new_email
     
     result_rest = rest_api.put(data)
     
     if result_rest == True and not new_email == self.user.username:
         self.user.username = new_email
         self.user.email = new_email
         self.user.save()
     
     rest_properties = RestProperties(username=self.user.username)
     for key in self.cleaned_data:
         # check for existing actions_value_N (always "true" if exists)
         if key.startswith('actions_value_'):
             if self.cleaned_data[key] != self.action_old_values[key]:
                 actionId = self.cleaned_data[key.replace('_value_', '_key_')]
                 
                 if self.cleaned_data[key] == True:
                     string_value = 'true'
                     if actionId == 'org.backmeup.indexer':
                         result_rest['messages'].append(_('Indexing new backup jobs has been activated.'))
                 else:    
                     string_value = 'false'
                     if actionId == 'org.backmeup.indexer':
                         result_rest['messages'].append(_('Indexing new backup jobs has been deactivated.'))
                         result_rest['index_deactivated'] = True
                         
                 result_property = rest_properties.post(actionId=actionId, value=string_value)
         
     return result_rest