Save segunda brancha as backup

This commit is contained in:
fjrodriguez
2023-01-20 10:20:45 -06:00
parent 35798c5304
commit 2e432ae674
10 changed files with 164 additions and 8 deletions

View File

@@ -31,6 +31,7 @@ urlpatterns = [
path('accounts/', include('allauth.urls')), path('accounts/', include('allauth.urls')),
path('DRF_Token/', obtain_auth_token, name='DRF_Token'), path('DRF_Token/', obtain_auth_token, name='DRF_Token'),
path('', include('Clientes.urls')), path('', include('Clientes.urls')),
path('sistemas/',include('Sistemas.urls')),
path('403/', permission_denied_view), path('403/', permission_denied_view),

View File

@@ -73,4 +73,6 @@ class Clientes(models.Model):
class Meta: class Meta:
ordering = ('-Activo','-conteo_mes','RFC') ordering = ('-Activo','-conteo_mes','RFC')
def __str__(self):
return self.Nombre

View File

@@ -1,3 +1,17 @@
from django.contrib import admin from django.contrib import admin
from .models import Sistema, sistemas_por_cliente
# Register your models here. # Register your models here.
class Sistema_Admin(admin.ModelAdmin):
def NSistema(self,obj):
return obj.nombre_sistema
list_display = ['NSistema']
class SPC(admin.ModelAdmin):
'''Sistemas Por Cliente'''
def Cliente(self,obj):
return obj
list_display = ['id_sistema','Cliente','num_licencias']
admin.site.register(Sistema,Sistema_Admin)
admin.site.register(sistemas_por_cliente,SPC)

View File

@@ -0,0 +1,32 @@
# Generated by Django 4.1.3 on 2023-01-19 19:43
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('Clientes', '0014_alter_clientes_options'),
]
operations = [
migrations.CreateModel(
name='Sistema',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nombre_sistema', models.CharField(max_length=100, unique=True)),
],
),
migrations.CreateModel(
name='sistemas_por_cliente',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('num_licencias', models.IntegerField(default=1)),
('cliente', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='cliente_spc', to='Clientes.clientes')),
('id_sistema', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sistema_spc', to='Sistemas.sistema')),
],
),
]

View File

@@ -1,28 +1,39 @@
from django.db import models from django.db import models
from Clientes.models import Clientes from Clientes.models import Clientes
# Create your models here.
class Sistema(models.Model): class Sistema(models.Model):
nombre_sistema= models.CharField(max_length=100, blank=False,null=False,unique=True) nombre_sistema= models.CharField(max_length=100, blank=False,null=False,unique=True)
# class Meta: # class Meta:
# abstract=True # abstract=True
def __str__(self):
return self.nombre_sistema
class sistemas_por_cliente(models.Model): class sistemas_por_cliente(models.Model):
id_sistema= models.ForeignKey(Sistema, related_name='sistema_spc', on_delete=models.CASCADE) id_sistema= models.ForeignKey(Sistema, related_name='sistema_spc', on_delete=models.CASCADE)
cliente = models.ForeignKey(Clientes, related_name='cliente_spc', on_delete=models.CASCADE) cliente = models.ForeignKey(Clientes, related_name='cliente_spc', on_delete=models.CASCADE)
num_licencias= models.IntegerField(default=1) num_licencias= models.IntegerField(default=1)
# class Meta: def __str__(self):
# abstract = True
return self.cliente.Nombre
class Meta:
ordering= ('-cliente','id_sistema')
class Maquinas_Conectadas(models.Model): class Maquinas_Conectadas(models.Model):
UserName = models.CharField(max_length=255) UserName = models.CharField(max_length=255)
PC_Name = models.CharField(max_length=255) PC_Name = models.CharField(max_length=255)
Is64 = models.BooleanField() Is64 = models.BooleanField()
OSversion= models.CharField(max_length=255) OSversion= models.CharField(max_length=255)
local_ip = models.CharField(max_length=55) local_ip = models.CharField(max_length=55)
public_ip= models.CharField(max_length=55) public_ip= models.CharField(max_length=55)
RFC = models.CharField(max_length=13)
Token = models.CharField(max_length=50)
Cliente = models.CharField(max_length=13)
class Meta: class Meta:
abstract =True abstract =True

16
Sistemas/urls.py Normal file
View File

@@ -0,0 +1,16 @@
from django.urls import path
from .views import (
#CVB
SistemasXCliente_ListView,
SistemasXCliente_DetailView,
#DRF APIViews
Registrar_PC,
)
urlpatterns = [
path('',SistemasXCliente_ListView.as_view(),name='lista_sistmas'),
path('detail/<str:pk>/',SistemasXCliente_DetailView.as_view(),name='detail_sistemas'),
path('registerPC/',Registrar_PC.as_view(),name='register_PC'),
]

View File

@@ -1,3 +1,31 @@
from django.shortcuts import render from django.shortcuts import render
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
# Create your views here. from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework.permissions import IsAuthenticated
from rest_framework import status, permissions
from .models import sistemas_por_cliente
class SistemasXCliente_ListView(ListView):
model = sistemas_por_cliente
paginate_by = 5
template_name = 'Sistemas/Xclientes/lista.html'
class SistemasXCliente_DetailView(DetailView):
model = sistemas_por_cliente
template_name= 'Sistemas/Xclientes/detail.html'
#registrar Equipo
class Registrar_PC(APIView):
permissions_classes = (permissions.AllowAny,)
def post(self,request, format=None):
data = request.data
return Response(data)
def get(self,request):
pass

View File

@@ -0,0 +1,13 @@
{% extends 'base.html' %}
{% block title %}
{{object}} | Sistemas
{% endblock title %}
{% block content %}
<h1>{{object.cliente}}</h1>
{{object.id_sistema}} <br>
{{object.num_licencias}}
{% endblock content %}

View File

@@ -0,0 +1,36 @@
{% extends "base.html" %}
{% block title %}
Sistemas Lista
{% endblock title %}
{% block content %}
<table class="table">
<thead class="thead-dark">
<tr>
<th scope="col">#</th>
<th scope="col">Sistema</th>
<th scope="col">Cliente</th>
<th scope="col">No. Licencias</th>
<th></th>
</tr>
</thead>
<tbody>
{% for row in object_list %}
<tr>
<th scope="row">{{row.id}}</th>
<td>{{row.id_sistema}}</td>
<td>{{row.cliente}}</td>
<td>{{row.num_licencias}}</td>
<td><a href="{% url 'detail_sistemas' row.id %}" class="btn btn-info">Detalles</a></td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock content %}

View File

@@ -39,8 +39,11 @@
<li class="nav-item"> <li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a> <a class="nav-link disabled" href="#">Disabled</a>
</li> </li>
{% endcomment %}
{% endcomment %}
<li class="nav-item">
<a class="nav-link" href="/sistemas" target="_blank">Sistemas</a>
</li>
{% if request.user.is_superuser %} {% if request.user.is_superuser %}
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="/admin" target="_blank">Admin site</a> <a class="nav-link" href="/admin" target="_blank">Admin site</a>