Modificacion de clientes form, CBV
This commit is contained in:
@@ -18,7 +18,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
SECRET_KEY = 'django-insecure-5*mm&uf5zq@t6nrs_5z8-_qtyapm^3&yz^wqqkc_a!v(!ulj-^'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = False
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
|
||||
@@ -33,6 +33,7 @@ INSTALLED_APPS = [
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
|
||||
|
||||
'allauth',
|
||||
'allauth.account',
|
||||
'allauth.socialaccount',
|
||||
|
||||
8
Clientes/forms.py
Normal file
8
Clientes/forms.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from django import forms
|
||||
from .models import Clientes
|
||||
|
||||
|
||||
class ClienteForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Clientes
|
||||
fields = ('RFC','Nombre','Activo','fecha_baja')
|
||||
@@ -1,8 +1,9 @@
|
||||
from django.urls import path,include
|
||||
from .views import index,add_timbre, timbres_cliente,saldo_funct
|
||||
from .views import index,add_timbre, timbres_cliente,saldo_funct,ClientesUpdateView
|
||||
urlpatterns = [
|
||||
path('', index, name='index'),
|
||||
path('add_timbre/', add_timbre, name='add_timbre'),
|
||||
path('timbres_cliente/<str:RFC>/', timbres_cliente, name='timbres_cliente'),
|
||||
path('get_saldo/', saldo_funct, name='saldo_funct'),
|
||||
path('cliente/update/<int:pk>/',ClientesUpdateView.as_view(),name='update_cliente'),
|
||||
]
|
||||
@@ -6,6 +6,9 @@ from .models import Clientes,Timbres,saldoModel,ErroresTimbres
|
||||
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||
from django.db.models import Q
|
||||
import datetime
|
||||
from django.views.generic.edit import UpdateView
|
||||
from .forms import ClienteForm
|
||||
|
||||
@login_required
|
||||
def index(request):
|
||||
|
||||
@@ -120,4 +123,11 @@ def saldo_funct(request):
|
||||
except:
|
||||
Saldo = saldoModel.objects.create(saldo=int(timbres))
|
||||
|
||||
return JsonResponse({'data':Saldo.saldo})
|
||||
return JsonResponse({'data':Saldo.saldo})
|
||||
|
||||
|
||||
class ClientesUpdateView(UpdateView):
|
||||
model= Clientes
|
||||
form_class=ClienteForm
|
||||
success_url='/'
|
||||
template_name='Clientes/edit_cliente.html'
|
||||
47
Templates/Clientes/edit_cliente.html
Normal file
47
Templates/Clientes/edit_cliente.html
Normal file
@@ -0,0 +1,47 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load widget_tweaks %}
|
||||
|
||||
{% block title %}Editar Cliente{% endblock title %}
|
||||
{% block titlePage %}RFC: {{object.RFC}}{% endblock titlePage %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<form method="POST" action=".">
|
||||
{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<label for="{{form.RFC.name}}"><strong> {{form.RFC.label|capfirst}} </strong></label>
|
||||
{% render_field form.RFC id+="add" id+=form.RFC.name placeholder=form.RFC.label class="form-control" type="text" autocomplete="off" %}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="{{form.Nombre.name}}"><strong> {{form.Nombre.label|capfirst}} </strong></label>
|
||||
{% render_field form.Nombre id+="add" id+=form.Nombre.name placeholder=form.Nombre.label class="form-control" type="text" autocomplete="off" %}
|
||||
</div>
|
||||
|
||||
<div class="form-group form-check">
|
||||
{% render_field form.Activo class+="form-checkbox" type="checkbox" %}
|
||||
<label class="form-check-label" for="{{form.Activo.label}}">Activo</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{% render_field form.fecha_baja.label %}
|
||||
{% render_field form.fecha_baja placeholder=form.fecha_baja.label class+="form-control" type="date" %}
|
||||
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</form>
|
||||
{% endblock content %}
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
id_fecha_baja.addEventListener('click',(event)=>{
|
||||
|
||||
if(id_Activo.checked){
|
||||
event.preventDefault()
|
||||
alert('El cliente esta activo necesita deseleccionar "Activo" y colocar fecha baja.')
|
||||
return
|
||||
}
|
||||
})
|
||||
</script>
|
||||
{% endblock scripts %}
|
||||
|
||||
|
||||
@@ -32,7 +32,9 @@
|
||||
<tbody>
|
||||
{% for obj in clientes %}
|
||||
<tr class="">
|
||||
<td>{{obj.RFC}}</td>
|
||||
<td>
|
||||
<a href="{% url 'update_cliente' obj.pk %}">{{obj.RFC}}</a>
|
||||
</td>
|
||||
<td>{{obj.Nombre}}</td>
|
||||
<td>{{obj.timbres_mes_count}}</td>
|
||||
<td>
|
||||
@@ -51,6 +53,7 @@
|
||||
table_rfcc.addEventListener('click',(event)=>{
|
||||
document.getElementById('rfcc').checked= table_rfcc.checked? true:false;
|
||||
})
|
||||
add
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
22
req.text
Normal file
22
req.text
Normal file
@@ -0,0 +1,22 @@
|
||||
asgiref==3.5.2
|
||||
certifi==2022.9.24
|
||||
cffi==1.15.1
|
||||
charset-normalizer==2.1.1
|
||||
cryptography==38.0.3
|
||||
defusedxml==0.7.1
|
||||
Django==4.1.3
|
||||
django-allauth==0.51.0
|
||||
django-widget-tweaks==1.4.12
|
||||
djangorestframework==3.14.0
|
||||
idna==3.4
|
||||
oauthlib==3.2.2
|
||||
pycparser==2.21
|
||||
PyJWT==2.6.0
|
||||
PyMySQL==1.0.2
|
||||
python3-openid==3.2.0
|
||||
pytz==2022.6
|
||||
requests==2.28.1
|
||||
requests-oauthlib==1.3.1
|
||||
sqlparse==0.4.3
|
||||
tzdata==2022.6
|
||||
urllib3==1.26.13
|
||||
Reference in New Issue
Block a user