2019-03-08 11:47:50 +00:00
|
|
|
"""passbook PropertyMapping administration"""
|
2019-10-10 12:01:49 +01:00
|
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
2019-12-31 11:51:16 +00:00
|
|
|
from django.contrib.auth.mixins import (
|
|
|
|
PermissionRequiredMixin as DjangoPermissionRequiredMixin,
|
|
|
|
)
|
2019-03-08 11:47:50 +00:00
|
|
|
from django.contrib.messages.views import SuccessMessageMixin
|
|
|
|
from django.urls import reverse_lazy
|
|
|
|
from django.utils.translation import ugettext as _
|
2019-10-10 12:01:49 +01:00
|
|
|
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
2019-03-08 11:47:50 +00:00
|
|
|
|
2020-07-01 23:13:33 +01:00
|
|
|
from passbook.admin.views.utils import (
|
|
|
|
DeleteMessageView,
|
|
|
|
InheritanceCreateView,
|
|
|
|
InheritanceListView,
|
|
|
|
InheritanceUpdateView,
|
|
|
|
)
|
2019-03-08 11:47:50 +00:00
|
|
|
from passbook.core.models import PropertyMapping
|
|
|
|
|
|
|
|
|
2020-07-01 23:13:33 +01:00
|
|
|
class PropertyMappingListView(
|
|
|
|
LoginRequiredMixin, PermissionListMixin, InheritanceListView
|
|
|
|
):
|
2019-03-08 11:47:50 +00:00
|
|
|
"""Show list of all property_mappings"""
|
|
|
|
|
|
|
|
model = PropertyMapping
|
2019-12-31 11:51:16 +00:00
|
|
|
permission_required = "passbook_core.view_propertymapping"
|
|
|
|
template_name = "administration/property_mapping/list.html"
|
|
|
|
ordering = "name"
|
2019-10-14 12:15:42 +01:00
|
|
|
paginate_by = 40
|
2019-03-08 11:47:50 +00:00
|
|
|
|
|
|
|
|
2019-12-31 11:51:16 +00:00
|
|
|
class PropertyMappingCreateView(
|
|
|
|
SuccessMessageMixin,
|
|
|
|
LoginRequiredMixin,
|
|
|
|
DjangoPermissionRequiredMixin,
|
2020-07-01 23:13:33 +01:00
|
|
|
InheritanceCreateView,
|
2019-12-31 11:51:16 +00:00
|
|
|
):
|
2019-03-08 11:47:50 +00:00
|
|
|
"""Create new PropertyMapping"""
|
|
|
|
|
2019-10-10 12:01:49 +01:00
|
|
|
model = PropertyMapping
|
2019-12-31 11:51:16 +00:00
|
|
|
permission_required = "passbook_core.add_propertymapping"
|
2019-10-10 12:01:49 +01:00
|
|
|
|
2019-12-31 11:51:16 +00:00
|
|
|
template_name = "generic/create.html"
|
|
|
|
success_url = reverse_lazy("passbook_admin:property-mappings")
|
|
|
|
success_message = _("Successfully created Property Mapping")
|
2019-03-08 11:47:50 +00:00
|
|
|
|
|
|
|
|
2019-12-31 11:51:16 +00:00
|
|
|
class PropertyMappingUpdateView(
|
2020-07-01 23:13:33 +01:00
|
|
|
SuccessMessageMixin,
|
|
|
|
LoginRequiredMixin,
|
|
|
|
PermissionRequiredMixin,
|
|
|
|
InheritanceUpdateView,
|
2019-12-31 11:51:16 +00:00
|
|
|
):
|
2019-03-08 11:47:50 +00:00
|
|
|
"""Update property_mapping"""
|
|
|
|
|
|
|
|
model = PropertyMapping
|
2019-12-31 11:51:16 +00:00
|
|
|
permission_required = "passbook_core.change_propertymapping"
|
2019-10-10 12:01:49 +01:00
|
|
|
|
2019-12-31 11:51:16 +00:00
|
|
|
template_name = "generic/update.html"
|
|
|
|
success_url = reverse_lazy("passbook_admin:property-mappings")
|
|
|
|
success_message = _("Successfully updated Property Mapping")
|
2019-03-08 11:47:50 +00:00
|
|
|
|
|
|
|
|
2019-12-31 11:51:16 +00:00
|
|
|
class PropertyMappingDeleteView(
|
2020-07-01 23:13:33 +01:00
|
|
|
LoginRequiredMixin, PermissionRequiredMixin, DeleteMessageView
|
2019-12-31 11:51:16 +00:00
|
|
|
):
|
2019-03-08 11:47:50 +00:00
|
|
|
"""Delete property_mapping"""
|
|
|
|
|
|
|
|
model = PropertyMapping
|
2019-12-31 11:51:16 +00:00
|
|
|
permission_required = "passbook_core.delete_propertymapping"
|
2019-10-10 12:01:49 +01:00
|
|
|
|
2019-12-31 11:51:16 +00:00
|
|
|
template_name = "generic/delete.html"
|
|
|
|
success_url = reverse_lazy("passbook_admin:property-mappings")
|
|
|
|
success_message = _("Successfully deleted Property Mapping")
|