Ejemplo n.º 1
0
import pymobile.administration.utils as u
import logging

# Get an instance of a logger
logger = logging.getLogger("file")

# Create your views here.

TMP_ADMIN="cliente/admin.html"
TMP_FORM="cliente/modelform.html"
TMP_DEL="cliente/deleteform.html"
TMP_VIEW="cliente/view.html"

@login_required
#@user_passes_test(lambda user: not u.is_telefonista(user),)
@user_passes_test(lambda user: u.get_group(user) != "telefonista")
def init(request):
    template = TMP_ADMIN
    objs = models.Cliente.objects.all()
    initial = {}
    pag = 1
    ordering = None
    
    if request.method == "GET" and request.GET:
        query_get = request.GET.copy()
        initial = {}
        
        if query_get.has_key("pag"):
            pag = query_get["pag"]
            del query_get["pag"]
        if query_get.has_key("sort"):
Ejemplo n.º 2
0
                            window.location.href = '{}';
                        </script>
                        '''. format(reverse("login")))

@login_required     
def logout_user(request):
    user = request.user
    auth.logout(request)
    logger.debug("{}: logout".format(user))
    # Redirect to a success page.
    messages.add_message(request, messages.SUCCESS, 'Logout effettuato')
    return HttpResponseRedirect(reverse("login"))

@login_required
#@user_passes_test(lambda user: not u.is_telefonista(user),)
@user_passes_test(lambda user: not u.get_group(user) == "telefonista")
def init(request):
    template = TMP_ADMIN
    objs = User.objects.filter(is_superuser=False)
    
    initial = {}
    pag = 1
    ordering = None
    
    if request.method == "GET" and request.GET:
        query_get = request.GET.copy()
        initial = {}
        
        if query_get.has_key("pag"):
            pag = query_get["pag"]
            del query_get["pag"]