Beispiel #1
0
 def process_request(self, request):
     try:
         config = VestatConfiguration.objects.get(pk=settings.ID_CONFIG)
     except VestatConfiguration.DoesNotExist:
         config = VestatConfiguration(id=settings.ID_CONFIG)
         config.save()
         info(request, "Configuração criada.")
Beispiel #2
0
    def post(self, request, *args, **kwargs):
        machine = shortcuts.get_object_or_404(self.model, pk=self.kwargs.get('pk'))
        force = request.GET.get('force')        
        
        form = self.__get_form(machine, request.POST)
        if force:
            form.force = True
 
        if form.is_valid():
            if not form.has_changed():
                form.reset_errors()
                api.info(request, _(u'Nenhuma alteração efetuada'))
                return shortcuts.render(request, self.template_name, {'form': form,
                                                                      'object': machine})
            
            machine = form.save()
            
            api.success(request, _(u'Máquina alterada com sucesso'))
            
            if form.dynamic_pool_full:
                api.warning(request, _(u'O pool associado a máquina tem mais máquinas do que IPs disponíveis.'))
            
            models.Log(user=request.user, msg=_(u"Máquina '%s' alterada" % machine.mac)).save()
            return shortcuts.redirect(urlresolvers.reverse('webradius:mac_detail', args=(machine.id,)))
        
        if form.dynamic_ip_in_use:
            return shortcuts.render(request, self.template_force_name, {'form': form,
                                                                        'object': machine})
        else:
            return shortcuts.render(request, self.template_name, {'form': form,
                                                                  'object': machine})
Beispiel #3
0
 def process_request(self, request):
     try:
         Registro.objects.get(nome=NOME_DO_REGISTRO)
     except Registro.DoesNotExist:
         r = Registro(nome=NOME_DO_REGISTRO)
         r.save()
         info(request, "Registro de contabilidade criado")
Beispiel #4
0
 def process_request(self, request):
     try:
         Registro.objects.get(nome=NOME_DO_REGISTRO)
     except Registro.DoesNotExist:
         r = Registro(nome=NOME_DO_REGISTRO)
         r.save()
         info(request, "Registro de contabilidade criado")
Beispiel #5
0
 def process_request(self, request):
     try:
         config = VestatConfiguration.objects.get(pk=settings.ID_CONFIG)
     except VestatConfiguration.DoesNotExist:
         config = VestatConfiguration(id=settings.ID_CONFIG)
         config.save()
         info(request, "Configuração criada.")
Beispiel #6
0
def user_create(request):
    form = CreateForm(request.POST or None)
    if form.is_valid():
        form.save()
        info(request, _('Account added, please wait for an admin to verify.'))
        return HttpResponseRedirect(reverse("index"))
    return direct_to_template(request, "user_create.html", extra_context={
        "form": form,
    })
Beispiel #7
0
 def process_request(self, request):
     try:
         db_name = settings.DATABASES['default']['NAME']
         db = open(db_name)
         db.close()
     except IOError:
         call_command("syncdb", interactive=False)
         info(request, "Banco de dados criado.")
         criar_superusuario()
         info(request, "Superusuário criado.")
Beispiel #8
0
def user_password(request):
    form = PasswordForm(request.user, request.POST or None)
    if form.is_valid():
        form.save()
        info(request, 'Password changed.')
        return HttpResponseRedirect(reverse("user-edit",
                                            args=[request.user.pk]))
    return direct_to_template(request, "user_password.html", extra_context={
        "form": form,
    })
Beispiel #9
0
 def process_request(self, request):
     try:
         db_name = settings.DATABASES['default']['NAME']
         db = open(db_name)
         db.close()
     except IOError:
         call_command("syncdb", interactive=False)
         info(request, "Banco de dados criado.")
         criar_superusuario()
         info(request, "Superusuário criado.")
Beispiel #10
0
def user_edit(request, pk):
    form = EditForm(request.POST or None, instance=User.objects.get(pk=pk))
    if form.is_valid():
        form.save()
        info(request, 'User details changed.')
        return HttpResponseRedirect(reverse("user-list"))
    return direct_to_template(request, "user_edit.html", extra_context={
        "form": form,
        "nav": {"selected": "users",},
    })
Beispiel #11
0
def user_create(request):
    form = CreateForm(request.POST or None)
    if form.is_valid():
        form.save()
        info(request, _('Account added, please wait for an admin to verify.'))
        return HttpResponseRedirect(reverse("index"))
    return direct_to_template(request,
                              "user_create.html",
                              extra_context={
                                  "form": form,
                              })
Beispiel #12
0
def user_password(request):
    form = PasswordForm(request.user, request.POST or None)
    if form.is_valid():
        form.save()
        info(request, 'Password changed.')
        return HttpResponseRedirect(
            reverse("user-edit", args=[request.user.pk]))
    return direct_to_template(request,
                              "user_password.html",
                              extra_context={
                                  "form": form,
                              })
Beispiel #13
0
 def get(self, request, *args, **kwargs):
     mac = self.kwargs.get('mac')
     if mac is not None:
         form_initial = {'mac': mac}                    
         form = macinfo.MacAddForm(initial=form_initial)
     else:
         form = macinfo.MacAddForm()
             
     if models.Poolinfo.objects.all().exclude(pool_name__startswith='static').count() == 0:
         api.info(request, _(u'Não há nenhum Pool de endereços cadastrado ainda'))
         return shortcuts.redirect(urlresolvers.reverse('webradius:mac_list'))
     return shortcuts.render(request, self.template_name, {'form': form})
Beispiel #14
0
def user_edit(request, pk):
    form = EditForm(request.POST or None, instance=User.objects.get(pk=pk))
    if form.is_valid():
        form.save()
        info(request, 'User details changed.')
        return HttpResponseRedirect(reverse("user-list"))
    return direct_to_template(request,
                              "user_edit.html",
                              extra_context={
                                  "form": form,
                                  "nav": {
                                      "selected": "users",
                                  },
                              })
Beispiel #15
0
    def post(self, request, *args, **kwargs):
        nas_edit = shortcuts.get_object_or_404(self.model, pk=self.kwargs.get('pk'))
        form = nas.NASEditForm(request.POST, instance=nas_edit)

        if form.is_valid():            
            if not form.has_changed():
                api.info(request, _(u'Nenhuma alteração efetuada'))
                return shortcuts.render(request, self.template_name, {'form': form,
                                                            'object': nas_edit})
            
            if not form._errors:
                form.save()
                api.success(request, _(u'NAS alterado com sucesso'))
                models.Log(user=request.user, msg=_(u"NAS '%s' alterado" % nas_edit.nasname)).save()
                return shortcuts.redirect(urlresolvers.reverse('webradius:nas_list')) 
        return shortcuts.render(request, self.template_name, {'form': form,
                                                    'object': nas_edit})
Beispiel #16
0
    def post(self, request, *args, **kwargs):
        pool_edit = shortcuts.get_object_or_404(self.model, pk=self.kwargs.get('pk'))
        
        if pool_edit.pool_name.startswith(models.Poolinfo.get_static_prefix()):
            return shortcuts.redirect(urlresolvers.reverse('handler403'))
        
        form = poolinfo.PoolEditForm(request.POST, instance=pool_edit)

        if form.is_valid():
            if not form.has_changed():
                api.info(request, _(u'Nenhuma alteração efetuada'))
                form.reset_errors()
                return shortcuts.render(request, self.template_name, {'form': form,
                                                                      'object': pool_edit})
            
            pool = form.save()
            
            api.success(request, _(u'Pool alterado com sucesso'))
            models.Log(user=request.user, msg=_(u"Pool '%s' alterado" % pool_edit.pool_name)).save()
            return shortcuts.redirect(urlresolvers.reverse('webradius:pool_detail', args=(pool.id,))) 
        return shortcuts.render(request, self.template_name, {'form': form,
                                                              'object': pool_edit})
Beispiel #17
0
def auth_processor_messages(request):
    info(request, "Message 1")
    return render(request, 'context_processors/auth_attrs_messages.html')
Beispiel #18
0
def auth_processor_messages(request):
    info(request, "Message 1")
    return render(request, 'context_processors/auth_attrs_messages.html')
Beispiel #19
0
def auth_processor_messages(request):
    info(request, "Message 1")
    return render_to_response(
        'context_processors/auth_attrs_messages.html',
        RequestContext(request, {}, processors=[context_processors.auth]))
Beispiel #20
0
def auth_processor_messages(request):
    info(request, "Message 1")
    return render_to_response(
        "context_processors/auth_attrs_messages.html", RequestContext(request, {}, processors=[context_processors.auth])
    )