combo/combo/apps/maps/manager_views.py

52 lines
1.7 KiB
Python

# combo - content management system
# Copyright (C) 2017 Entr'ouvert
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.core.urlresolvers import reverse_lazy
from django.views.generic import (TemplateView, ListView, CreateView,
UpdateView, DeleteView)
from .models import Map
from .models import MapLayer
from .forms import MapNewLayerForm, MapLayerForm
class MapLayerMixin(object):
model = MapLayer
success_url = reverse_lazy('maps-manager-homepage')
class ManagerHomeView(MapLayerMixin, ListView):
template_name = 'maps/manager_home.html'
def get_context_data(self, **kwargs):
context = super(ManagerHomeView, self).get_context_data(**kwargs)
context['map_list'] = Map.objects.all()
return context
class LayerAddView(MapLayerMixin, CreateView):
form_class = MapNewLayerForm
template_name = 'maps/map_layer_form.html'
class LayerEditView(MapLayerMixin, UpdateView):
form_class = MapLayerForm
template_name = 'maps/map_layer_form.html'
class LayerDeleteView(MapLayerMixin, DeleteView):
template_name = 'maps/map_layer_confirm_delete.html'