From 555d7bf56a80359a6b00dd5172233c012b46504f Mon Sep 17 00:00:00 2001 From: Sesostris Vieira Date: Thu, 1 Nov 2012 12:35:53 +0000 Subject: [PATCH] =?UTF-8?q?App=20Eventos=20-=20in=C3=ADcio=20do=20desenvol?= =?UTF-8?q?vimento.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pydevproject | 20 ++++++++++---------- sigi/apps/eventos/__init__.py | 0 sigi/apps/eventos/admin.py | 7 +++++++ sigi/apps/eventos/models.py | 28 ++++++++++++++++++++++++++++ sigi/apps/eventos/tests.py | 23 +++++++++++++++++++++++ sigi/apps/eventos/views.py | 1 + sigi/sites.py | 3 +++ 7 files changed, 72 insertions(+), 10 deletions(-) create mode 100644 sigi/apps/eventos/__init__.py create mode 100644 sigi/apps/eventos/admin.py create mode 100644 sigi/apps/eventos/models.py create mode 100644 sigi/apps/eventos/tests.py create mode 100644 sigi/apps/eventos/views.py diff --git a/.pydevproject b/.pydevproject index a2ba8c5..c8c785a 100644 --- a/.pydevproject +++ b/.pydevproject @@ -1,21 +1,19 @@ - - - + - python + Python 2.7 with django-1.2 - python 2.6 + python 2.7 @@ -23,11 +21,13 @@ - DJANGO_MANAGE_LOCATION - sigi/manage.py - sigi - /home/sesostris/workspace/sigi/sigi - +DJANGO_MANAGE_LOCATION +sigi/manage.py +sigi +/home/sesostris/workspace/sigi/sigi +DJANGO_SETTINGS_MODULE +sigi.settings + diff --git a/sigi/apps/eventos/__init__.py b/sigi/apps/eventos/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sigi/apps/eventos/admin.py b/sigi/apps/eventos/admin.py new file mode 100644 index 0000000..9d0913d --- /dev/null +++ b/sigi/apps/eventos/admin.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +from django.contrib import admin +from sigi.apps.eventos.models import Recurso + +class RecursoAdmin(admin.ModelAdmin): + list_display = ('nome', 'quantidade',) + pass \ No newline at end of file diff --git a/sigi/apps/eventos/models.py b/sigi/apps/eventos/models.py new file mode 100644 index 0000000..23930c9 --- /dev/null +++ b/sigi/apps/eventos/models.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +from django.db import models + +class Recurso(models.Model): + nome = models.CharField(u'Nome', max_length=60) + descricao = models.TextField(u'Descrição', help_text = 'Descrição detalhada do recurso', blank=True) + quantidade = models.PositiveIntegerField(u'Quantidade', 'Quantidade disponível do recurso no Interlegis. Use 9999 para infinito') + + class Meta: + verbose_name, verbose_name_plural = 'Recurso', 'Recursos' + + def __unicode__(self): + return self.nome; + + def qtde_disponivel(self, data_inicio, data_fim): + """ + Given a date range, return the available quantity of recourse in that period. + """ + #TODO: Write the code when Evento model is done + return self.quantidade + + def reservar(self, evento, data_inicio, data_fim): + """ + Lock a quantity of resource to an 'evento' in timeslice between 'data_inicio' and 'data_fim' + Return True if successfull or False otherwise + """ + # TODO: Write code when Evento model is done + return True diff --git a/sigi/apps/eventos/tests.py b/sigi/apps/eventos/tests.py new file mode 100644 index 0000000..2247054 --- /dev/null +++ b/sigi/apps/eventos/tests.py @@ -0,0 +1,23 @@ +""" +This file demonstrates two different styles of tests (one doctest and one +unittest). These will both pass when you run "manage.py test". + +Replace these with more appropriate tests for your application. +""" + +from django.test import TestCase + +class SimpleTest(TestCase): + def test_basic_addition(self): + """ + Tests that 1 + 1 always equals 2. + """ + self.failUnlessEqual(1 + 1, 2) + +__test__ = {"doctest": """ +Another way to test that 1 + 1 is equal to 2. + +>>> 1 + 1 == 2 +True +"""} + diff --git a/sigi/apps/eventos/views.py b/sigi/apps/eventos/views.py new file mode 100644 index 0000000..60f00ef --- /dev/null +++ b/sigi/apps/eventos/views.py @@ -0,0 +1 @@ +# Create your views here. diff --git a/sigi/sites.py b/sigi/sites.py index b3ffeac..7737089 100644 --- a/sigi/sites.py +++ b/sigi/sites.py @@ -32,6 +32,7 @@ from sigi.apps.servidores.admin import (Servidor, ServidorAdmin, Funcao, FuncaoA Ferias, FeriasAdmin, Licenca, LicencaAdmin) from sigi.apps.ocorrencias.admin import (Ocorrencia, OcorrenciaAdmin, Anexo as AnexoOcorrencia, AnexoAdmin as AnexoOcorrenciaAdmin, Categoria) +from sigi.apps.eventos.admin import (Recurso, RecursoAdmin) class DefaultSite(AdminSite): index_template = 'index.html' @@ -112,3 +113,5 @@ default.register(Ocorrencia, OcorrenciaAdmin) default.register(AnexoOcorrencia, AnexoOcorrenciaAdmin) default.register(Categoria) +# sigi.apps.eventos +default.register(Recurso, RecursoAdmin)