def ssh_passwd(request): u = request.session.get('switched_user', request.user) superuser = request.user if request.method == 'POST': form = PassCheckForm(request.POST) if form.is_valid(): sr = SystemRequest(u, u.parms.web_machine) sr.passwd(form.cleaned_data["password1"]) messages.add_message(request, messages.SUCCESS, _('Password has been changed')) return HttpResponseRedirect(reverse("wsgiadmin.useradmin.views.ok")) else: form = PassCheckForm() return render_to_response('universal.html', { "form": form, "form_helper": RostiFormHelper(), "title": _("Change password for SSH/FTP"), "u": u, "superuser": superuser, "menu_active": "settings", }, context_instance=RequestContext(request) )
def form_valid(self, form): self.object = form.save(commit=False) self.object.owner = self.request.user ret = super(CronCreateView, self).form_valid(form) sr = SystemRequest(self.user, self.user.parms.web_machine) sr.cron(self.user) messages.add_message(self.request, messages.SUCCESS, _('Cron record has been created')) return ret
def remove_cron(request): u = request.session.get('switched_user', request.user) superuser = request.user try: cron = request.user.cron_set.get(id=int(request.POST.get("object_id"))) cron.delete() sr = SystemRequest(request.user, request.user.parms.web_machine) sr.cron(request.user) return JsonResponse("OK", {1: ugettext("Cron record was successfuly removed")}) except Exception, e: return JsonResponse("KO", {1: ugettext("Error deleting cron record")})
def form_valid(self, form): ret = super(CronUpdateView, self).form_valid(form) sr = SystemRequest(self.user, self.user.parms.web_machine) sr.cron(self.user) messages.add_message(self.request, messages.SUCCESS, _('Cron record has been updated')) return ret