mirror of https://github.com/interlegis/sigi.git
Sesostris Vieira
12 years ago
7 changed files with 72 additions and 10 deletions
@ -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 |
@ -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 |
@ -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 |
|||
"""} |
|||
|
@ -0,0 +1 @@ |
|||
# Create your views here. |
Loading…
Reference in new issue