def get_productos_mayor_rotacion(request): role = getRole(request) email = getUserEmail(request) tendero = Tendero.objects.get(correo=email) if role == "Tendero Principal": productos = get_productos_recomendados(tendero.tienda.id) productos_list = serializers.serialize('json', productos) return productos
def variable_list(request): role = getRole(request) if role == "Gerencia Campus": variables = get_variables() context = {'variable_list': variables} return render(request, 'Variable/variables.html', context) else: return HttpResponse("Unauthorized User")
def measurement_list(request): role = getRole(request) if role == "Supervisor": measurements = get_measurements() context = {'measurement_list': measurements} return render(request, 'Measurement/measurements.html', context) else: return HttpResponse("Unauthorized User")
def get_tenderos(request): role = getRole(request) if request.user.is_authenticated and role == "CEO": tenderos = get_all_tenderos() tendero_list = serializers.serialize('json', tenderos) return HttpResponse(tendero_list, content_type='application/json') else: return HttpResponse("Unauthorized User")
def boletin_list(request): role = getRole(request) if role == "Profesor" or "Miembro Comunidad": boletines = get_boletines() context = { 'boletin_list': boletines } return render(request, 'Boletin/boletines.html', context) else: return HttpResponse("Unauthorized User")
def variable_edit(request, variable_id): role = getRole(request) if role == "Admin" or role == "Disenador": instancia = Variable.objects.get(id=variable_id) form = VariableForm(instance=instancia) if request.method == 'POST': form = VariableForm(request.POST, instance=instancia) if form.is_valid(): instancia = form.save(commit=False) instancia.save() return render(request, "Variable/variableEdit.html", {'form': form}) else: return HttpResponse("Usuario no Autorizado")
def variable_create(request): role = getRole(request) if role == "Admin": if request.method == 'POST': form = VariableForm(request.POST) if form.is_valid(): create_variable(form) messages.add_message(request, messages.SUCCESS, 'Se creo de forma exitosa el producto') return HttpResponseRedirect(reverse('variableCreate')) else: print(form.errors) else: form = VariableForm() context = { 'form': form, } return render(request, 'Variable/variableCreate.html', context) else: return HttpResponse("Usuario no Autorizado")
def authentication(request): #Se obtiene el rol del usuario role = getRole(request) if role == "Tendero Principal": #Se obtiene el email del usuario que ingresa email = getUserEmail(request) tendero = Tendero.objects.get(correo=email) context = {"data": tendero} return render(request, 'tenderoLogin.html', context) elif role == "CEO": return render(request, 'ceo.html') else: return HttpResponse("Unauthorized user")
def boletin_create(request): role = getRole(request) if role == "Profesor": if request.method == 'POST': form = BoletinForm(request.POST) if form.is_valid(): create_boletin(form) messages.add_message(request, messages.SUCCESS, 'Successfully created boletin') return HttpResponseRedirect(reverse('boletinCreate')) else: print(form.errors) else: form = BoletinForm() context = { 'form': form, } return render(request, 'Boletin/boletinCreate.html', context) else: return HttpResponse("Unauthorized User")
def variable_create(request): role = getRole(request) if role == "Gerencia Campus": if request.method == 'POST': form = VariableForm(request.POST) if form.is_valid(): create_variable(form) messages.add_message(request, messages.SUCCESS, 'Successfully created variable') return HttpResponseRedirect(reverse('variableCreate')) else: print(form.errors) else: form = VariableForm() context = { 'form': form, } return render(request, 'Variable/variableCreate.html', context) else: return HttpResponse("Unauthorized User")