Browse Source

Substitui model serviço pelo TipoServiço já existente no sigi

pull/6/head
Eduardo Edson Batista Cordeiro Alves 9 years ago
committed by Luciano Almeida
parent
commit
c8eb8e2e1d
  1. 9
      sigi/apps/solicitacoes/forms.py
  2. 24
      sigi/apps/solicitacoes/migrations/0005_auto_20160627_1349.py
  3. 19
      sigi/apps/solicitacoes/models.py
  4. 3
      sigi/apps/solicitacoes/urls.py
  5. 18
      sigi/apps/solicitacoes/views.py
  6. 1
      templates/base.html

9
sigi/apps/solicitacoes/forms.py

@ -3,7 +3,7 @@ from django.db import transaction
from django import forms from django import forms
from django.forms import ModelForm from django.forms import ModelForm
from sigi.settings.prod import OSTICKET_API_KEY, OSTICKET_URL from sigi.settings.prod import OSTICKET_API_KEY, OSTICKET_URL
from .models import Sistema, Solicitacao from .models import Solicitacao
import json import json
import requests import requests
@ -67,10 +67,3 @@ class SolicitacaoEditForm(ModelForm):
u'casa_legislativa', u'titulo', u'resumo'] u'casa_legislativa', u'titulo', u'resumo']
widgets = {u'codigo': forms.TextInput(attrs={u'readonly': u'readonly'}), widgets = {u'codigo': forms.TextInput(attrs={u'readonly': u'readonly'}),
u'usuario': forms.HiddenInput()} u'usuario': forms.HiddenInput()}
class SistemaForm(ModelForm):
class Meta(object):
model = Sistema
fields = [u'sigla', u'nome']

24
sigi/apps/solicitacoes/migrations/0005_auto_20160627_1349.py

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-06-27 13:49
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('solicitacoes', '0004_solicitacao_osticket'),
]
operations = [
migrations.AlterField(
model_name='solicitacao',
name='sistema',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='servicos.TipoServico'),
),
migrations.DeleteModel(
name='Sistema',
),
]

19
sigi/apps/solicitacoes/models.py

@ -4,28 +4,13 @@ from django.db import models
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from sigi.apps.usuarios.models import Usuario from sigi.apps.usuarios.models import Usuario
from sigi.apps.servicos.models import TipoServico
class Sistema(models.Model):
sigla = models.CharField(verbose_name=_(u'Sigla'), max_length=10)
nome = models.CharField(verbose_name=_(u'Nome Sistema'),
max_length=100)
descricao = models.TextField(null=True,
blank=True,
verbose_name=_(u'Descrição'))
class Meta(object):
verbose_name = _(u'Sistema')
verbose_name_plural = _(u'Sistemas')
def __str__(self):
return u"%s - %s" % (self.sigla, self.nome)
class Solicitacao(models.Model): class Solicitacao(models.Model):
codigo = models.PositiveIntegerField(unique=True) codigo = models.PositiveIntegerField(unique=True)
usuario = models.ForeignKey(Usuario) usuario = models.ForeignKey(Usuario)
sistema = models.ForeignKey(Sistema) sistema = models.ForeignKey(TipoServico)
titulo = models.CharField(verbose_name=_(u'Título'), max_length=100) titulo = models.CharField(verbose_name=_(u'Título'), max_length=100)
resumo = models.CharField(verbose_name=_(u'Resumo'), max_length=50) resumo = models.CharField(verbose_name=_(u'Resumo'), max_length=50)
casa_legislativa = models.CharField(verbose_name=_(u'Casa Legislativa'), casa_legislativa = models.CharField(verbose_name=_(u'Casa Legislativa'),

3
sigi/apps/solicitacoes/urls.py

@ -1,14 +1,13 @@
from __future__ import absolute_import from __future__ import absolute_import
from django.conf.urls import include, url from django.conf.urls import include, url
from sigi.apps.solicitacoes.views import SistemaCrud, SolicitacaoCrud from sigi.apps.solicitacoes.views import SolicitacaoCrud
from .apps import AppConfig from .apps import AppConfig
app_name = AppConfig.name app_name = AppConfig.name
urlpatterns = [ urlpatterns = [
url(ur'home/atendimento/sistema/', include(SistemaCrud.get_urls())),
url(ur'home/atendimento/solicitacao/', url(ur'home/atendimento/solicitacao/',
include(SolicitacaoCrud.get_urls())), include(SolicitacaoCrud.get_urls())),
] ]

18
sigi/apps/solicitacoes/views.py

@ -8,8 +8,8 @@ import sigi.apps.crud.base
from sigi.apps.crud.base import Crud, CrudCreateView, CrudListView, CrudCreateView, CrudUpdateView, CrudBaseMixin from sigi.apps.crud.base import Crud, CrudCreateView, CrudListView, CrudCreateView, CrudUpdateView, CrudBaseMixin
from sigi.apps.usuarios.models import Usuario from sigi.apps.usuarios.models import Usuario
from .forms import SistemaForm, SolicitacaoEditForm, SolicitacaoForm from .forms import SolicitacaoEditForm, SolicitacaoForm
from .models import Sistema, Solicitacao from .models import Solicitacao
class SolicitacaoCrud(LoginRequiredMixin, Crud): class SolicitacaoCrud(LoginRequiredMixin, Crud):
@ -48,17 +48,3 @@ class SolicitacaoCrud(LoginRequiredMixin, Crud):
class BaseMixin(CrudBaseMixin): class BaseMixin(CrudBaseMixin):
list_field_names = [u'osticket', u'sistema', list_field_names = [u'osticket', u'sistema',
u'titulo', u'data_criacao'] u'titulo', u'data_criacao']
class SistemaCrud(Crud):
model = Sistema
help_path = u''
class CreateView(LoginRequiredMixin, CrudCreateView):
form_class = SistemaForm
class UpdateView(LoginRequiredMixin, CrudUpdateView):
form_class = SistemaForm
class ListView(LoginRequiredMixin, CrudListView):
pass

1
templates/base.html

@ -37,7 +37,6 @@
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
{% if user.is_authenticated %} {% if user.is_authenticated %}
<li><a href="{% url 'solicitacoes:solicitacao_list' %}">Solicitação</a></li> <li><a href="{% url 'solicitacoes:solicitacao_list' %}">Solicitação</a></li>
<li><a href="{% url 'solicitacoes:sistema_list' %}">Sistema</a></li>
<li><a href="{% url 'usuarios:usuario_list' %}">Habilitar</a></li> <li><a href="{% url 'usuarios:usuario_list' %}">Habilitar</a></li>
{% endif %} {% endif %}
</ul> </ul>

Loading…
Cancel
Save