예제 #1
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)
    )
예제 #2
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