def init_obiettivo_trimestrale(request): template = TMP_ADMIN # determiniamo solo gli obiettivi attivi objs = models.Obiettivo.objects.filter(data_fine__isnull=True) 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"): ordering = query_get["sort"] del query_get["sort"] if query_get: objs, initial = u.filter_objs(objs, query_get) table = tables.ObiettivoTable(objs, order_by=(ordering,)) table.paginate(page=pag) if request.is_ajax(): template = table.as_html() return HttpResponse(template) data = {"modeltable": table,} return render_to_response(template, data, context_instance=RequestContext(request))
def init(request): template = TMP_ADMIN objs = models.Dipendente.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"): ordering = query_get["sort"] del query_get["sort"] if query_get: objs, initial = u.filter_objs(objs, query_get) table = tables.DipendenteTable(objs, order_by=(ordering,)) table.paginate(page=pag) if request.is_ajax(): template = table.as_html() return HttpResponse(template) filterform = forms.DipendenteFilterForm(initial=initial) data = {"modeltable": table, "filterform": filterform} return render_to_response(template, data, context_instance=RequestContext(request))
def init_attribute(request, attribute): template = "tariffa/attribute_admin.html" model = get_model("administration", attribute + "tariffa") objs = model.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"): ordering = query_get["sort"] del query_get["sort"] if query_get: objs, initial = u.filter_objs(objs, query_get) table = u.get_table(attribute + "tariffatable")(objs, order_by=(ordering,)) table.paginate(page=pag) if request.is_ajax(): template = table.as_html() return HttpResponse(template) filterform = u.get_form(attribute + "tariffafilterform")(initial=initial) data = {"modeltable": table, "filterform": filterform, "attributo": attribute,} return render_to_response(template, data, context_instance=RequestContext(request))
def init(request): template = TMP_ADMIN if u.is_telefonista(request.user): user = request.user profile = user.dipendente objs = models.Appuntamento.objects.filter(agente__isnull=True, telefonista=profile,) else: objs = models.Appuntamento.objects.all() # determiniamo gli agenti per l'assegnazione, devono essere solo quelli attivi # il giorno successivo day = datetime.datetime.today().date() + datetime.timedelta(1) agenti = models.Dipendente.objects.filter(ruolo="agt", data_assunzione__lte=day)\ .exclude(data_licenziamento__lt=day) 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"): ordering = query_get["sort"] del query_get["sort"] if query_get: objs, initial = u.filter_objs(objs, query_get) table = tables.AppuntamentoTable(objs, order_by=(ordering,)) table.paginate(page=pag) if request.is_ajax(): template = table.as_html() return HttpResponse(template) filterform = forms.AppuntamentoFilterForm(initial=initial) data = {"modeltable": table, "filterform": filterform, "agenti": agenti} return render_to_response(template, data, context_instance=RequestContext(request))
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"): ordering = query_get["sort"] del query_get["sort"] if query_get.has_key("fgestore"): gestore = query_get["fgestore"][1:] excluded = [] for obj in objs: if not obj.contratto_set.filter(piano_tariffario__gestore=gestore).exists(): excluded.append(obj.id) objs = objs.exclude(id__in=excluded) del query_get["fgestore"] initial["gestore"] = gestore if query_get: objs, initial_values = u.filter_objs(objs, query_get) for k, v in initial_values.iteritems(): initial[k] = v table = tables.ClienteTable(objs, order_by=(ordering,)) table.paginate(page=pag) if request.is_ajax(): template = table.as_html() return HttpResponse(template) filterform = forms.ClienteFilterForm(initial=initial) data = {"modeltable": table, "filterform": filterform} return render_to_response(template, data, context_instance=RequestContext(request))