|
@ -3,17 +3,17 @@ |
|
|
# sigi.apps.eventos.admin |
|
|
# sigi.apps.eventos.admin |
|
|
# |
|
|
# |
|
|
# Copyright (C) 2015 Interlegis |
|
|
# Copyright (C) 2015 Interlegis |
|
|
# |
|
|
# |
|
|
# This program is free software; you can redistribute it and/or |
|
|
# This program is free software; you can redistribute it and/or |
|
|
# modify it under the terms of the GNU General Public License |
|
|
# modify it under the terms of the GNU General Public License |
|
|
# as published by the Free Software Foundation; either version 2 |
|
|
# as published by the Free Software Foundation; either version 2 |
|
|
# of the License, or (at your option) any later version. |
|
|
# of the License, or (at your option) any later version. |
|
|
# |
|
|
# |
|
|
# This program is distributed in the hope that it will be useful, |
|
|
# This program is distributed in the hope that it will be useful, |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
# GNU General Public License for more details. |
|
|
# GNU General Public License for more details. |
|
|
# |
|
|
# |
|
|
# You should have received a copy of the GNU General Public License |
|
|
# You should have received a copy of the GNU General Public License |
|
|
# along with this program; if not, write to the Free Software |
|
|
# along with this program; if not, write to the Free Software |
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
@ -26,19 +26,22 @@ from sigi.apps.eventos.models import TipoEvento, Funcao, Evento, Equipe, Convite |
|
|
class EventoAdminForm(forms.ModelForm): |
|
|
class EventoAdminForm(forms.ModelForm): |
|
|
class Meta: |
|
|
class Meta: |
|
|
model = Evento |
|
|
model = Evento |
|
|
fields = ('tipo_evento', 'nome', 'descricao', 'solicitante', 'data_inicio', 'data_termino', |
|
|
fields = ('tipo_evento', 'nome', 'descricao', 'virtual', 'solicitante', |
|
|
'casa_anfitria', 'municipio', 'local', 'publico_alvo', 'status', |
|
|
'data_inicio', 'data_termino', 'carga_horaria', |
|
|
'data_cancelamento', 'motivo_cancelamento', ) |
|
|
'casa_anfitria', 'municipio', 'local', 'publico_alvo', |
|
|
|
|
|
'status', 'data_cancelamento', 'motivo_cancelamento', ) |
|
|
|
|
|
|
|
|
def clean(self): |
|
|
def clean(self): |
|
|
cleaned_data = super(EventoAdminForm, self).clean() |
|
|
cleaned_data = super(EventoAdminForm, self).clean() |
|
|
data_inicio = cleaned_data.get("data_inicio") |
|
|
data_inicio = cleaned_data.get("data_inicio") |
|
|
data_termino = cleaned_data.get("data_termino") |
|
|
data_termino = cleaned_data.get("data_termino") |
|
|
|
|
|
|
|
|
if data_inicio > data_termino: |
|
|
if data_inicio > data_termino: |
|
|
raise forms.ValidationError(_(u"Data término deve ser posterior à data inicio"), |
|
|
raise forms.ValidationError( |
|
|
code="invalid_period" ) |
|
|
_(u"Data término deve ser posterior à data inicio"), |
|
|
|
|
|
code="invalid_period" |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
@admin.register(TipoEvento) |
|
|
@admin.register(TipoEvento) |
|
|
class TipoEventAdmin(admin.ModelAdmin): |
|
|
class TipoEventAdmin(admin.ModelAdmin): |
|
|
search_fields = ('nome',) |
|
|
search_fields = ('nome',) |
|
@ -47,24 +50,23 @@ class TipoEventAdmin(admin.ModelAdmin): |
|
|
class FuncaoAdmin(admin.ModelAdmin): |
|
|
class FuncaoAdmin(admin.ModelAdmin): |
|
|
list_display = ('nome', 'descricao',) |
|
|
list_display = ('nome', 'descricao',) |
|
|
search_fields = ('nome', 'descricao',) |
|
|
search_fields = ('nome', 'descricao',) |
|
|
|
|
|
|
|
|
class EquipeInline(admin.TabularInline): |
|
|
class EquipeInline(admin.TabularInline): |
|
|
model = Equipe |
|
|
model = Equipe |
|
|
|
|
|
|
|
|
class ConviteInline(admin.TabularInline): |
|
|
class ConviteInline(admin.TabularInline): |
|
|
model = Convite |
|
|
model = Convite |
|
|
raw_id_fields = ('casa',) |
|
|
raw_id_fields = ('casa',) |
|
|
|
|
|
|
|
|
@admin.register(Evento) |
|
|
@admin.register(Evento) |
|
|
class EventoAdmin(admin.ModelAdmin): |
|
|
class EventoAdmin(admin.ModelAdmin): |
|
|
form = EventoAdminForm |
|
|
form = EventoAdminForm |
|
|
date_hierarchy = 'data_inicio' |
|
|
date_hierarchy = 'data_inicio' |
|
|
list_display = ('nome', 'tipo_evento', 'status', 'data_inicio', 'data_termino', 'municipio', |
|
|
list_display = ('nome', 'tipo_evento', 'status', 'data_inicio', |
|
|
'solicitante') |
|
|
'data_termino', 'municipio', 'solicitante') |
|
|
list_filter = ('status', 'tipo_evento', 'municipio__uf', 'solicitante') |
|
|
list_filter = ('status', 'tipo_evento', 'virtual', 'municipio__uf', |
|
|
|
|
|
'solicitante') |
|
|
raw_id_fields = ('casa_anfitria', 'municipio',) |
|
|
raw_id_fields = ('casa_anfitria', 'municipio',) |
|
|
search_fields = ('nome', 'tipo_evento__nome', 'casa_anfitria__search_text', |
|
|
search_fields = ('nome', 'tipo_evento__nome', 'casa_anfitria__search_text', |
|
|
'municipio__search_text', 'solicitante') |
|
|
'municipio__search_text', 'solicitante') |
|
|
inlines = (EquipeInline, ConviteInline) |
|
|
inlines = (EquipeInline, ConviteInline) |
|
|
|
|
|
|
|
|
|
|
|
|