Rename Service.name --> Service.api_name
Avoid collision name attributes with service data.
This commit is contained in:
parent
0fa3408035
commit
c8e8f778d7
|
@ -2,13 +2,13 @@ from django.utils.html import format_html
|
||||||
|
|
||||||
|
|
||||||
class Service:
|
class Service:
|
||||||
name = None
|
api_name = None
|
||||||
verbose_name = None
|
verbose_name = None
|
||||||
fields = ()
|
fields = ()
|
||||||
|
|
||||||
def __init__(self, data={}):
|
def __init__(self, data={}):
|
||||||
if self.verbose_name is None:
|
if self.verbose_name is None:
|
||||||
self.verbose_name = self.name
|
self.verbose_name = self.api_name
|
||||||
|
|
||||||
self.data = data
|
self.data = data
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ class Service:
|
||||||
|
|
||||||
|
|
||||||
class MailService(Service):
|
class MailService(Service):
|
||||||
name = 'address'
|
api_name = 'address'
|
||||||
verbose_name = 'Mail'
|
verbose_name = 'Mail'
|
||||||
fields = ('mail_address', 'aliases', 'type', 'type_detail')
|
fields = ('mail_address', 'aliases', 'type', 'type_detail')
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ class MailService(Service):
|
||||||
|
|
||||||
|
|
||||||
class MailinglistService(Service):
|
class MailinglistService(Service):
|
||||||
name = 'mailinglist'
|
api_name = 'mailinglist'
|
||||||
verbose_name = 'Mailing list'
|
verbose_name = 'Mailing list'
|
||||||
fields = ('name', 'status', 'address_name', 'admin_email', 'configure')
|
fields = ('name', 'status', 'address_name', 'admin_email', 'configure')
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
|
from itertools import groupby
|
||||||
|
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from itertools import groupby
|
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
|
@ -13,8 +14,8 @@ from . import api, get_version
|
||||||
from .auth import login as auth_login
|
from .auth import login as auth_login
|
||||||
from .auth import logout as auth_logout
|
from .auth import logout as auth_logout
|
||||||
from .forms import LoginForm
|
from .forms import LoginForm
|
||||||
from .mixins import CustomContextMixin, ExtendedPaginationMixin, UserTokenRequiredMixin
|
from .mixins import (CustomContextMixin, ExtendedPaginationMixin, UserTokenRequiredMixin)
|
||||||
from .models import MailService, MailinglistService
|
from .models import DatabaseService, MailinglistService, MailService
|
||||||
|
|
||||||
|
|
||||||
class DashboardView(CustomContextMixin, UserTokenRequiredMixin, TemplateView):
|
class DashboardView(CustomContextMixin, UserTokenRequiredMixin, TemplateView):
|
||||||
|
@ -35,15 +36,15 @@ class DashboardView(CustomContextMixin, UserTokenRequiredMixin, TemplateView):
|
||||||
|
|
||||||
class ServiceListView(CustomContextMixin, ExtendedPaginationMixin, UserTokenRequiredMixin, ListView):
|
class ServiceListView(CustomContextMixin, ExtendedPaginationMixin, UserTokenRequiredMixin, ListView):
|
||||||
"""Base list view to all services"""
|
"""Base list view to all services"""
|
||||||
service = None
|
service_class = None
|
||||||
template_name = "musician/service_list.html" # TODO move to ServiceListView
|
template_name = "musician/service_list.html" # TODO move to ServiceListView
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
if self.service_class is None or self.service_class.name is None:
|
if self.service_class is None or self.service_class.api_name is None:
|
||||||
raise ImproperlyConfigured(
|
raise ImproperlyConfigured(
|
||||||
"ServiceListView requires a definiton of 'service'")
|
"ServiceListView requires a definiton of 'service'")
|
||||||
|
|
||||||
json_qs = self.orchestra.retrieve_service_list(self.service_class.name)
|
json_qs = self.orchestra.retrieve_service_list(self.service_class.api_name)
|
||||||
return [self.service_class(data) for data in json_qs]
|
return [self.service_class(data) for data in json_qs]
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
|
@ -68,7 +69,7 @@ class MailView(ServiceListView):
|
||||||
|
|
||||||
# group addresses with the same mailbox
|
# group addresses with the same mailbox
|
||||||
raw_data = self.orchestra.retrieve_service_list(
|
raw_data = self.orchestra.retrieve_service_list(
|
||||||
self.service_class.name)
|
self.service_class.api_name)
|
||||||
addresses = []
|
addresses = []
|
||||||
for key, group in groupby(raw_data, retrieve_mailbox):
|
for key, group in groupby(raw_data, retrieve_mailbox):
|
||||||
aliases = []
|
aliases = []
|
||||||
|
|
Loading…
Reference in New Issue