django4: fix default AppConfig deprecation warnings (#68585)
This commit is contained in:
parent
9492991c9d
commit
aa576e205f
|
@ -13,23 +13,3 @@
|
|||
#
|
||||
# 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.assets'
|
||||
verbose_name = _('Assets')
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
||||
|
||||
def get_extra_manager_actions(self):
|
||||
return [{'href': reverse('combo-manager-assets'), 'text': _('Assets')}]
|
||||
|
||||
|
||||
default_app_config = 'combo.apps.assets.AppConfig'
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
# combo - content management system
|
||||
# Copyright (C) 2017-2018 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.assets'
|
||||
verbose_name = _('Assets')
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
||||
|
||||
def get_extra_manager_actions(self):
|
||||
return [{'href': reverse('combo-manager-assets'), 'text': _('Assets')}]
|
|
@ -13,19 +13,3 @@
|
|||
#
|
||||
# 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.calendar'
|
||||
verbose_name = _('Calendar')
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
||||
|
||||
|
||||
default_app_config = 'combo.apps.calendar.AppConfig'
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
# 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.calendar'
|
||||
verbose_name = _('Calendar')
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
|
@ -10,30 +10,3 @@
|
|||
# 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.
|
||||
|
||||
import django.apps
|
||||
from django.utils.timezone import now, timedelta
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.dashboard'
|
||||
verbose_name = _('Dashboard')
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
||||
|
||||
def hourly(self):
|
||||
self.clean_autotiles()
|
||||
|
||||
def clean_autotiles(self):
|
||||
from combo.data.models import ConfigJsonCell
|
||||
|
||||
ConfigJsonCell.objects.filter(
|
||||
placeholder='_auto_tile', last_update_timestamp__lte=now() - timedelta(days=2)
|
||||
).delete()
|
||||
|
||||
|
||||
default_app_config = 'combo.apps.dashboard.AppConfig'
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
# combo - content management system
|
||||
# Copyright (C) 2014-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.
|
||||
|
||||
import django.apps
|
||||
from django.utils.timezone import now, timedelta
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.dashboard'
|
||||
verbose_name = _('Dashboard')
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
||||
|
||||
def hourly(self):
|
||||
self.clean_autotiles()
|
||||
|
||||
def clean_autotiles(self):
|
||||
from combo.data.models import ConfigJsonCell
|
||||
|
||||
ConfigJsonCell.objects.filter(
|
||||
placeholder='_auto_tile', last_update_timestamp__lte=now() - timedelta(days=2)
|
||||
).delete()
|
|
@ -13,27 +13,3 @@
|
|||
#
|
||||
# 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.dataviz'
|
||||
verbose_name = _('Data Visualisation')
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
||||
|
||||
def hourly(self):
|
||||
from .models import ChartNgCell
|
||||
from .utils import update_available_statistics
|
||||
|
||||
update_available_statistics()
|
||||
for cell in ChartNgCell.objects.all():
|
||||
cell.check_validity()
|
||||
|
||||
|
||||
default_app_config = 'combo.apps.dataviz.AppConfig'
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
# combo - content management system
|
||||
# Copyright (C) 2015 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.dataviz'
|
||||
verbose_name = _('Data Visualisation')
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
||||
|
||||
def hourly(self):
|
||||
from .models import ChartNgCell
|
||||
from .utils import update_available_statistics
|
||||
|
||||
update_available_statistics()
|
||||
for cell in ChartNgCell.objects.all():
|
||||
cell.check_validity()
|
|
@ -13,14 +13,3 @@
|
|||
#
|
||||
# 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.family'
|
||||
verbose_name = _('Family')
|
||||
|
||||
|
||||
default_app_config = 'combo.apps.family.AppConfig'
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
# combo - content management system
|
||||
# Copyright (C) 2021 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.family'
|
||||
verbose_name = _('Family')
|
|
@ -13,14 +13,3 @@
|
|||
#
|
||||
# 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.fargo'
|
||||
verbose_name = _('Portfolio')
|
||||
|
||||
|
||||
default_app_config = 'combo.apps.fargo.AppConfig'
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
# combo - content management system
|
||||
# Copyright (C) 2016 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.fargo'
|
||||
verbose_name = _('Portfolio')
|
|
@ -13,19 +13,3 @@
|
|||
#
|
||||
# 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.gallery'
|
||||
verbose_name = _('Gallery')
|
||||
|
||||
def get_after_manager_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.gallery_manager_urls
|
||||
|
||||
|
||||
default_app_config = 'combo.apps.gallery.AppConfig'
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
# combo - content management system
|
||||
# Copyright (C) 2015 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.gallery'
|
||||
verbose_name = _('Gallery')
|
||||
|
||||
def get_after_manager_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.gallery_manager_urls
|
|
@ -13,14 +13,3 @@
|
|||
#
|
||||
# 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.kb'
|
||||
verbose_name = _('Knowledge Base')
|
||||
|
||||
|
||||
default_app_config = 'combo.apps.kb.AppConfig'
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
# combo - content management system
|
||||
# Copyright (C) 2020 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.kb'
|
||||
verbose_name = _('Knowledge Base')
|
|
@ -13,93 +13,3 @@
|
|||
#
|
||||
# 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/>.
|
||||
|
||||
import datetime
|
||||
import logging
|
||||
|
||||
import django.apps
|
||||
import eopayment
|
||||
from django.db import transaction
|
||||
from django.db.models.signals import post_migrate
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.lingo'
|
||||
verbose_name = _('Payment')
|
||||
|
||||
def ready(self):
|
||||
post_migrate.connect(self.post_migrate_handler, sender=self)
|
||||
|
||||
def post_migrate_handler(self, **kwargs):
|
||||
from .models import PaymentBackend
|
||||
|
||||
with transaction.atomic():
|
||||
for payment_backend in PaymentBackend.objects.all():
|
||||
service_options = payment_backend.service_options
|
||||
transaction_options = {}
|
||||
for parameter in payment_backend.eopayment.get_parameters(scope='transaction'):
|
||||
name = parameter['name']
|
||||
if name in service_options:
|
||||
transaction_options[name] = service_options.pop(name)
|
||||
if not transaction_options:
|
||||
continue
|
||||
payment_backend.save()
|
||||
for regie in payment_backend.regie_set.all():
|
||||
# merge old values in new transactions options
|
||||
regie.transaction_options = dict(transaction_options, **regie.transaction_options)
|
||||
regie.save()
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
||||
|
||||
def get_extra_manager_actions(self):
|
||||
return [{'href': reverse('lingo-manager-homepage'), 'text': _('Online Payment')}]
|
||||
|
||||
def hourly(self):
|
||||
self.update_transactions()
|
||||
self.notify_payments()
|
||||
|
||||
def update_transactions(self):
|
||||
from .models import EXPIRED, Transaction
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
now = timezone.now()
|
||||
to_expire = Transaction.objects.filter(
|
||||
start_date__lt=now - datetime.timedelta(hours=1), end_date__isnull=True
|
||||
)
|
||||
for transaction in to_expire:
|
||||
logger.info('transaction %r is expired', transaction.order_id)
|
||||
transaction.status = EXPIRED
|
||||
transaction.save()
|
||||
|
||||
to_retry = Transaction.objects.filter(
|
||||
status__in=(eopayment.PAID, eopayment.ACCEPTED),
|
||||
to_be_paid_remote_items__isnull=False,
|
||||
start_date__gt=now - datetime.timedelta(days=4),
|
||||
)
|
||||
for transaction in to_retry:
|
||||
transaction.retry_notify_remote_items_of_payments()
|
||||
|
||||
def notify_payments(self):
|
||||
from combo.apps.lingo.models import BasketItem
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
now = timezone.now()
|
||||
for item in BasketItem.objects.filter(
|
||||
notification_date__isnull=True,
|
||||
cancellation_date__isnull=True,
|
||||
payment_date__lt=now - datetime.timedelta(minutes=5),
|
||||
payment_date__gt=now - datetime.timedelta(minutes=300),
|
||||
):
|
||||
try:
|
||||
item.notify_payment()
|
||||
except Exception:
|
||||
logger.exception('error in async notification for basket item %s', item.id)
|
||||
|
||||
|
||||
default_app_config = 'combo.apps.lingo.AppConfig'
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
# lingo - basket and payment system
|
||||
# Copyright (C) 2015 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/>.
|
||||
|
||||
import datetime
|
||||
import logging
|
||||
|
||||
import django.apps
|
||||
import eopayment
|
||||
from django.db import transaction
|
||||
from django.db.models.signals import post_migrate
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.lingo'
|
||||
verbose_name = _('Payment')
|
||||
|
||||
def ready(self):
|
||||
post_migrate.connect(self.post_migrate_handler, sender=self)
|
||||
|
||||
def post_migrate_handler(self, **kwargs):
|
||||
from .models import PaymentBackend
|
||||
|
||||
with transaction.atomic():
|
||||
for payment_backend in PaymentBackend.objects.all():
|
||||
service_options = payment_backend.service_options
|
||||
transaction_options = {}
|
||||
for parameter in payment_backend.eopayment.get_parameters(scope='transaction'):
|
||||
name = parameter['name']
|
||||
if name in service_options:
|
||||
transaction_options[name] = service_options.pop(name)
|
||||
if not transaction_options:
|
||||
continue
|
||||
payment_backend.save()
|
||||
for regie in payment_backend.regie_set.all():
|
||||
# merge old values in new transactions options
|
||||
regie.transaction_options = dict(transaction_options, **regie.transaction_options)
|
||||
regie.save()
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
||||
|
||||
def get_extra_manager_actions(self):
|
||||
return [{'href': reverse('lingo-manager-homepage'), 'text': _('Online Payment')}]
|
||||
|
||||
def hourly(self):
|
||||
self.update_transactions()
|
||||
self.notify_payments()
|
||||
|
||||
def update_transactions(self):
|
||||
from .models import EXPIRED, Transaction
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
now = timezone.now()
|
||||
to_expire = Transaction.objects.filter(
|
||||
start_date__lt=now - datetime.timedelta(hours=1), end_date__isnull=True
|
||||
)
|
||||
for transaction in to_expire:
|
||||
logger.info('transaction %r is expired', transaction.order_id)
|
||||
transaction.status = EXPIRED
|
||||
transaction.save()
|
||||
|
||||
to_retry = Transaction.objects.filter(
|
||||
status__in=(eopayment.PAID, eopayment.ACCEPTED),
|
||||
to_be_paid_remote_items__isnull=False,
|
||||
start_date__gt=now - datetime.timedelta(days=4),
|
||||
)
|
||||
for transaction in to_retry:
|
||||
transaction.retry_notify_remote_items_of_payments()
|
||||
|
||||
def notify_payments(self):
|
||||
from combo.apps.lingo.models import BasketItem
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
now = timezone.now()
|
||||
for item in BasketItem.objects.filter(
|
||||
notification_date__isnull=True,
|
||||
cancellation_date__isnull=True,
|
||||
payment_date__lt=now - datetime.timedelta(minutes=5),
|
||||
payment_date__gt=now - datetime.timedelta(minutes=300),
|
||||
):
|
||||
try:
|
||||
item.notify_payment()
|
||||
except Exception:
|
||||
logger.exception('error in async notification for basket item %s', item.id)
|
|
@ -13,23 +13,3 @@
|
|||
#
|
||||
# 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.maps'
|
||||
verbose_name = _('Maps')
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
||||
|
||||
def get_extra_manager_actions(self):
|
||||
return [{'href': reverse('maps-manager-homepage'), 'text': _('Maps')}]
|
||||
|
||||
|
||||
default_app_config = 'combo.apps.maps.AppConfig'
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
# 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.maps'
|
||||
verbose_name = _('Maps')
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
||||
|
||||
def get_extra_manager_actions(self):
|
||||
return [{'href': reverse('maps-manager-homepage'), 'text': _('Maps')}]
|
|
@ -13,19 +13,3 @@
|
|||
#
|
||||
# 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.notifications'
|
||||
verbose_name = _('Notification')
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
||||
|
||||
|
||||
default_app_config = 'combo.apps.notifications.AppConfig'
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
# combo - content management system
|
||||
# Copyright (C) 2016 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.notifications'
|
||||
verbose_name = _('Notification')
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
||||
|
||||
|
||||
default_app_config = 'combo.apps.notifications.AppConfig'
|
|
@ -13,17 +13,3 @@
|
|||
#
|
||||
# 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/>.
|
||||
|
||||
import django.apps
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.publik'
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
||||
|
||||
|
||||
default_app_config = 'combo.apps.publik.AppConfig'
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
# combo - content management system
|
||||
# Copyright (C) 2015 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/>.
|
||||
|
||||
import django.apps
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.publik'
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
|
@ -13,29 +13,3 @@
|
|||
#
|
||||
# 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.pwa'
|
||||
|
||||
def ready(self):
|
||||
from . import signals # noqa pylint: disable=unused-import
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
||||
|
||||
def get_extra_manager_actions(self):
|
||||
from django.conf import settings
|
||||
|
||||
if settings.TEMPLATE_VARS.get('pwa_display') == 'standalone':
|
||||
return [{'href': reverse('pwa-manager-homepage'), 'text': _('Mobile Application (PWA)')}]
|
||||
return []
|
||||
|
||||
|
||||
default_app_config = 'combo.apps.pwa.AppConfig'
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
# combo - content management system
|
||||
# Copyright (C) 2015-2018 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.pwa'
|
||||
|
||||
def ready(self):
|
||||
from . import signals # noqa pylint: disable=unused-import
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
||||
|
||||
def get_extra_manager_actions(self):
|
||||
from django.conf import settings
|
||||
|
||||
if settings.TEMPLATE_VARS.get('pwa_display') == 'standalone':
|
||||
return [{'href': reverse('pwa-manager-homepage'), 'text': _('Mobile Application (PWA)')}]
|
||||
return []
|
|
@ -12,42 +12,5 @@
|
|||
# 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
# along with this program. If not, see <http://www.
|
||||
from .engines import engines
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.search'
|
||||
verbose_name = _('Search')
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
||||
|
||||
def hourly(self):
|
||||
from .utils import index_site
|
||||
|
||||
index_site()
|
||||
|
||||
def ready(self):
|
||||
# register built-in search engine for page contents
|
||||
engines.register(self.get_search_engines)
|
||||
|
||||
def get_search_engines(self):
|
||||
from .utils import search_site
|
||||
|
||||
return {
|
||||
'_text': {
|
||||
'function': search_site,
|
||||
'label': _('Page Contents'),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
default_app_config = 'combo.apps.search.AppConfig'
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
# combo - content management system
|
||||
# Copyright (C) 2014-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/>.
|
||||
|
||||
import django.apps
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from .engines import engines
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.search'
|
||||
verbose_name = _('Search')
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
||||
|
||||
def hourly(self):
|
||||
from .utils import index_site
|
||||
|
||||
index_site()
|
||||
|
||||
def ready(self):
|
||||
# register built-in search engine for page contents
|
||||
engines.register(self.get_search_engines)
|
||||
|
||||
def get_search_engines(self):
|
||||
from .utils import search_site
|
||||
|
||||
return {
|
||||
'_text': {
|
||||
'function': search_site,
|
||||
'label': _('Page Contents'),
|
||||
}
|
||||
}
|
|
@ -13,131 +13,3 @@
|
|||
#
|
||||
# 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/>.
|
||||
|
||||
import hashlib
|
||||
|
||||
import django.apps
|
||||
from django.conf import settings
|
||||
from django.urls import reverse
|
||||
from django.utils.encoding import force_bytes
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import pgettext_lazy
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.wcs'
|
||||
verbose_name = _('Forms')
|
||||
|
||||
def ready(self):
|
||||
from combo.apps.search import engines
|
||||
|
||||
engines.register(self.get_search_engines)
|
||||
|
||||
def get_search_engines(self):
|
||||
from .utils import get_wcs_services
|
||||
|
||||
wcs_services = get_wcs_services()
|
||||
if not wcs_services:
|
||||
return
|
||||
|
||||
engines = self.get_portal_agent_search_engines(wcs_services)
|
||||
engines.update(self.get_card_search_engines(wcs_services))
|
||||
|
||||
return engines
|
||||
|
||||
def get_card_search_engines(self, wcs_services):
|
||||
from combo.data.models import Page
|
||||
|
||||
from .utils import get_wcs_json
|
||||
|
||||
pages_with_sub_slug = Page.objects.exclude(sub_slug='')
|
||||
if not pages_with_sub_slug:
|
||||
return {}
|
||||
|
||||
engines = {}
|
||||
for key, service in wcs_services.items():
|
||||
card_models = get_wcs_json(service, 'api/cards/@list')
|
||||
for card in card_models.get('data') or []:
|
||||
card_id = '%s_id' % card['id']
|
||||
matching_pages = [
|
||||
p for p in pages_with_sub_slug if '<%s>' % card_id in p.sub_slug or p.sub_slug == card_id
|
||||
]
|
||||
if not matching_pages:
|
||||
continue
|
||||
card_page = matching_pages[0]
|
||||
card_page_base_url = card_page.get_online_url()
|
||||
label = card['text']
|
||||
if len(wcs_services.keys()) > 1:
|
||||
label = '%s (%s)' % (label, service['title'])
|
||||
engines['cards:%s:%s' % (hashlib.md5(force_bytes(key)).hexdigest()[:8], card['id'])] = {
|
||||
'url': (
|
||||
service['url'] + 'api/cards/' + card['id'] + '/list/'
|
||||
'{% if search_service.selected_custom_view %}{{ search_service.selected_custom_view }}{% endif %}'
|
||||
'?{% if not search_service.without_user %}NameID={{ user_nameid }}&{% endif %}'
|
||||
'q=%(q)s'
|
||||
),
|
||||
'custom_views': card.get('custom_views') or [],
|
||||
'label': label,
|
||||
'signature': True,
|
||||
'hit_url_template': card_page_base_url + '{{ id }}',
|
||||
'hit_label_template': '{% firstof digest text %}',
|
||||
}
|
||||
return engines
|
||||
|
||||
def get_portal_agent_search_engines(self, wcs_services):
|
||||
if not settings.TEMPLATE_VARS.get('is_portal_agent'):
|
||||
return {}
|
||||
|
||||
engines = {
|
||||
'tracking-code': {
|
||||
'url': reverse('wcs-tracking-code-search') + '?q=%(q)s',
|
||||
'label': _('Tracking Code'),
|
||||
}
|
||||
}
|
||||
for key, service in wcs_services.items():
|
||||
label = pgettext_lazy('user-forms', 'Forms')
|
||||
if len(wcs_services.keys()) > 1:
|
||||
label = pgettext_lazy('user-forms', 'Forms (%s)') % service['title']
|
||||
engines['formdata:%s' % hashlib.md5(force_bytes(key)).hexdigest()[:8]] = {
|
||||
'url': service['url']
|
||||
+ 'api/forms/?NameID={{user_nameid}}&status=all&ignore-roles=on&include-anonymised=off&q=%(q)s',
|
||||
'label': label,
|
||||
'signature': True,
|
||||
'hit_url_template': '{% if readable %}{{ form_url_backoffice }}{% endif %}',
|
||||
'hit_label_template': '{{ title }}',
|
||||
'hit_description_template': '{{ form_digest|default:"" }}',
|
||||
}
|
||||
return engines
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
||||
|
||||
def hourly(self):
|
||||
from combo.data.library import get_cell_classes
|
||||
from combo.data.models import CellBase
|
||||
|
||||
cell_classes = [c for c in self.get_models() if c in get_cell_classes()]
|
||||
for cell in CellBase.get_cells(cell_filter=lambda x: x in cell_classes, page__snapshot__isnull=True):
|
||||
if hasattr(cell, 'check_validity'):
|
||||
cell.check_validity()
|
||||
|
||||
self.update_db_cache()
|
||||
|
||||
def update_db_cache(self):
|
||||
from combo.data.models import CellBase
|
||||
|
||||
from .models import WcsCardCell, WcsCategoryCell, WcsFormCell, WcsFormsOfCategoryCell
|
||||
|
||||
models_to_update = [
|
||||
WcsFormCell,
|
||||
WcsCategoryCell,
|
||||
WcsFormsOfCategoryCell,
|
||||
WcsCardCell,
|
||||
]
|
||||
for cell in CellBase.get_cells(cell_filter=lambda x: x in models_to_update):
|
||||
cell.save()
|
||||
|
||||
|
||||
default_app_config = 'combo.apps.wcs.AppConfig'
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
# combo - content management system
|
||||
# Copyright (C) 2016 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/>.
|
||||
|
||||
import hashlib
|
||||
|
||||
import django.apps
|
||||
from django.conf import settings
|
||||
from django.urls import reverse
|
||||
from django.utils.encoding import force_bytes
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import pgettext_lazy
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.apps.wcs'
|
||||
verbose_name = _('Forms')
|
||||
|
||||
def ready(self):
|
||||
from combo.apps.search import engines
|
||||
|
||||
engines.register(self.get_search_engines)
|
||||
|
||||
def get_search_engines(self):
|
||||
from .utils import get_wcs_services
|
||||
|
||||
wcs_services = get_wcs_services()
|
||||
if not wcs_services:
|
||||
return
|
||||
|
||||
engines = self.get_portal_agent_search_engines(wcs_services)
|
||||
engines.update(self.get_card_search_engines(wcs_services))
|
||||
|
||||
return engines
|
||||
|
||||
def get_card_search_engines(self, wcs_services):
|
||||
from combo.data.models import Page
|
||||
|
||||
from .utils import get_wcs_json
|
||||
|
||||
pages_with_sub_slug = Page.objects.exclude(sub_slug='')
|
||||
if not pages_with_sub_slug:
|
||||
return {}
|
||||
|
||||
engines = {}
|
||||
for key, service in wcs_services.items():
|
||||
card_models = get_wcs_json(service, 'api/cards/@list')
|
||||
for card in card_models.get('data') or []:
|
||||
card_id = '%s_id' % card['id']
|
||||
matching_pages = [
|
||||
p for p in pages_with_sub_slug if '<%s>' % card_id in p.sub_slug or p.sub_slug == card_id
|
||||
]
|
||||
if not matching_pages:
|
||||
continue
|
||||
card_page = matching_pages[0]
|
||||
card_page_base_url = card_page.get_online_url()
|
||||
label = card['text']
|
||||
if len(wcs_services.keys()) > 1:
|
||||
label = '%s (%s)' % (label, service['title'])
|
||||
engines['cards:%s:%s' % (hashlib.md5(force_bytes(key)).hexdigest()[:8], card['id'])] = {
|
||||
'url': (
|
||||
service['url'] + 'api/cards/' + card['id'] + '/list/'
|
||||
'{% if search_service.selected_custom_view %}{{ search_service.selected_custom_view }}{% endif %}'
|
||||
'?{% if not search_service.without_user %}NameID={{ user_nameid }}&{% endif %}'
|
||||
'q=%(q)s'
|
||||
),
|
||||
'custom_views': card.get('custom_views') or [],
|
||||
'label': label,
|
||||
'signature': True,
|
||||
'hit_url_template': card_page_base_url + '{{ id }}',
|
||||
'hit_label_template': '{% firstof digest text %}',
|
||||
}
|
||||
return engines
|
||||
|
||||
def get_portal_agent_search_engines(self, wcs_services):
|
||||
if not settings.TEMPLATE_VARS.get('is_portal_agent'):
|
||||
return {}
|
||||
|
||||
engines = {
|
||||
'tracking-code': {
|
||||
'url': reverse('wcs-tracking-code-search') + '?q=%(q)s',
|
||||
'label': _('Tracking Code'),
|
||||
}
|
||||
}
|
||||
for key, service in wcs_services.items():
|
||||
label = pgettext_lazy('user-forms', 'Forms')
|
||||
if len(wcs_services.keys()) > 1:
|
||||
label = pgettext_lazy('user-forms', 'Forms (%s)') % service['title']
|
||||
engines['formdata:%s' % hashlib.md5(force_bytes(key)).hexdigest()[:8]] = {
|
||||
'url': service['url']
|
||||
+ 'api/forms/?NameID={{user_nameid}}&status=all&ignore-roles=on&include-anonymised=off&q=%(q)s',
|
||||
'label': label,
|
||||
'signature': True,
|
||||
'hit_url_template': '{% if readable %}{{ form_url_backoffice }}{% endif %}',
|
||||
'hit_label_template': '{{ title }}',
|
||||
'hit_description_template': '{{ form_digest|default:"" }}',
|
||||
}
|
||||
return engines
|
||||
|
||||
def get_before_urls(self):
|
||||
from . import urls
|
||||
|
||||
return urls.urlpatterns
|
||||
|
||||
def hourly(self):
|
||||
from combo.data.library import get_cell_classes
|
||||
from combo.data.models import CellBase
|
||||
|
||||
cell_classes = [c for c in self.get_models() if c in get_cell_classes()]
|
||||
for cell in CellBase.get_cells(cell_filter=lambda x: x in cell_classes, page__snapshot__isnull=True):
|
||||
if hasattr(cell, 'check_validity'):
|
||||
cell.check_validity()
|
||||
|
||||
self.update_db_cache()
|
||||
|
||||
def update_db_cache(self):
|
||||
from combo.data.models import CellBase
|
||||
|
||||
from .models import WcsCardCell, WcsCategoryCell, WcsFormCell, WcsFormsOfCategoryCell
|
||||
|
||||
models_to_update = [
|
||||
WcsFormCell,
|
||||
WcsCategoryCell,
|
||||
WcsFormsOfCategoryCell,
|
||||
WcsCardCell,
|
||||
]
|
||||
for cell in CellBase.get_cells(cell_filter=lambda x: x in models_to_update):
|
||||
cell.save()
|
|
@ -1 +0,0 @@
|
|||
default_app_config = 'combo.data.apps.DataConfig'
|
|
@ -14,10 +14,10 @@
|
|||
# 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.apps import AppConfig
|
||||
import django.apps
|
||||
|
||||
|
||||
class DataConfig(AppConfig):
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.data'
|
||||
verbose_name = 'data'
|
||||
|
||||
|
|
|
@ -49,17 +49,17 @@ class MissingGroups(ImportSiteError):
|
|||
def export_site(pages=True, cartography=True, pwa=True, assets=True, payment=True, site_settings=True):
|
||||
'''Dump site objects to JSON-dumpable dictionnary'''
|
||||
|
||||
if 'combo.apps.lingo' in settings.INSTALLED_APPS:
|
||||
if 'combo.apps.lingo.apps.AppConfig' in settings.INSTALLED_APPS:
|
||||
from combo.apps.lingo.models import PaymentBackend, Regie
|
||||
else:
|
||||
payment = False
|
||||
|
||||
if 'combo.apps.maps' in settings.INSTALLED_APPS:
|
||||
if 'combo.apps.maps.apps.AppConfig' in settings.INSTALLED_APPS:
|
||||
from combo.apps.maps.models import MapLayer
|
||||
else:
|
||||
cartography = False
|
||||
|
||||
if 'combo.apps.pwa' in settings.INSTALLED_APPS:
|
||||
if 'combo.apps.pwa.apps.AppConfig' in settings.INSTALLED_APPS:
|
||||
from combo.apps.pwa.models import PwaNavigationEntry, PwaSettings
|
||||
else:
|
||||
pwa = False
|
||||
|
@ -92,21 +92,21 @@ def import_site(data, if_empty=False, clean=False, request=None):
|
|||
# format.
|
||||
data = {'pages': data}
|
||||
|
||||
if 'combo.apps.lingo' in settings.INSTALLED_APPS:
|
||||
if 'combo.apps.lingo.apps.AppConfig' in settings.INSTALLED_APPS:
|
||||
from combo.apps.lingo.models import PaymentBackend, Regie
|
||||
|
||||
payment_support = True
|
||||
else:
|
||||
payment_support = False
|
||||
|
||||
if 'combo.apps.maps' in settings.INSTALLED_APPS:
|
||||
if 'combo.apps.maps.apps.AppConfig' in settings.INSTALLED_APPS:
|
||||
from combo.apps.maps.models import MapLayer
|
||||
|
||||
cartography_support = True
|
||||
else:
|
||||
cartography_support = False
|
||||
|
||||
if 'combo.apps.pwa' in settings.INSTALLED_APPS:
|
||||
if 'combo.apps.pwa.apps.AppConfig' in settings.INSTALLED_APPS:
|
||||
from combo.apps.pwa.models import PwaNavigationEntry, PwaSettings
|
||||
|
||||
pwa_support = True
|
||||
|
@ -185,7 +185,7 @@ def import_site_tar(fd, if_empty=False, clean=False, overwrite=False, request=No
|
|||
except KeyError:
|
||||
raise ImportSiteError(_('TAR file should provide _site.json file'))
|
||||
|
||||
if 'combo.apps.maps' in settings.INSTALLED_APPS:
|
||||
if 'combo.apps.maps.apps.AppConfig' in settings.INSTALLED_APPS:
|
||||
from combo.apps.maps.models import MapLayer
|
||||
|
||||
cartography_support = True
|
||||
|
|
|
@ -13,5 +13,3 @@
|
|||
#
|
||||
# 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/>.
|
||||
|
||||
default_app_config = 'combo.manager.apps.ManagerAppConfig'
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
# 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.apps import AppConfig
|
||||
import django.apps
|
||||
|
||||
|
||||
class ManagerAppConfig(AppConfig):
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.manager'
|
||||
|
||||
def ready(self):
|
||||
|
|
|
@ -16,10 +16,6 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import django.apps
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
def user_get_name_id(user):
|
||||
if not hasattr(user, '_name_id'):
|
||||
user._name_id = None
|
||||
|
@ -37,45 +33,3 @@ default_description_template = """{{ email|default:"" }}
|
|||
{% if address %} {{ address }}{% endif %}
|
||||
{% if zipcode %} {{ zipcode }}{% endif %}
|
||||
{% if city %} {{ city }}{% endif %}"""
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.profile'
|
||||
verbose_name = _('Profile')
|
||||
|
||||
def ready(self):
|
||||
from combo.apps.search import engines
|
||||
|
||||
engines.register(self.get_search_engines)
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
get_user_model().add_to_class('get_name_id', user_get_name_id)
|
||||
|
||||
def get_search_engines(self):
|
||||
from django.conf import settings
|
||||
|
||||
from combo.data.models import Page
|
||||
|
||||
user_page = Page.objects.filter(sub_slug='name_id').first()
|
||||
if not user_page:
|
||||
user_page = Page.objects.filter(sub_slug__contains='<name_id>').first()
|
||||
if not user_page:
|
||||
return
|
||||
user_page_base_url = user_page.get_online_url()
|
||||
|
||||
# return entry using first(&only) authentic (if it exists)
|
||||
for service in settings.KNOWN_SERVICES.get('authentic', {}).values():
|
||||
return {
|
||||
'users': {
|
||||
'url': service['url'] + 'api/users/?q=%(q)s',
|
||||
'label': _('Users'),
|
||||
'signature': True,
|
||||
'data_key': 'results',
|
||||
'hit_url_template': user_page_base_url + '{{uuid}}/',
|
||||
'hit_label_template': '{{first_name}} {{last_name}}',
|
||||
'hit_description_template': default_description_template,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
default_app_config = 'combo.profile.AppConfig'
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
import django.apps
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from . import default_description_template, user_get_name_id
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = 'combo.profile'
|
||||
verbose_name = _('Profile')
|
||||
|
||||
def ready(self):
|
||||
from combo.apps.search import engines
|
||||
|
||||
engines.register(self.get_search_engines)
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
get_user_model().add_to_class('get_name_id', user_get_name_id)
|
||||
|
||||
def get_search_engines(self):
|
||||
from django.conf import settings
|
||||
|
||||
from combo.data.models import Page
|
||||
|
||||
user_page = Page.objects.filter(sub_slug='name_id').first()
|
||||
if not user_page:
|
||||
user_page = Page.objects.filter(sub_slug__contains='<name_id>').first()
|
||||
if not user_page:
|
||||
return
|
||||
user_page_base_url = user_page.get_online_url()
|
||||
|
||||
# return entry using first(&only) authentic (if it exists)
|
||||
for service in settings.KNOWN_SERVICES.get('authentic', {}).values():
|
||||
return {
|
||||
'users': {
|
||||
'url': service['url'] + 'api/users/?q=%(q)s',
|
||||
'label': _('Users'),
|
||||
'signature': True,
|
||||
'data_key': 'results',
|
||||
'hit_url_template': user_page_base_url + '{{uuid}}/',
|
||||
'hit_label_template': '{{first_name}} {{last_name}}',
|
||||
'hit_description_template': default_description_template,
|
||||
}
|
||||
}
|
|
@ -59,25 +59,25 @@ INSTALLED_APPS = (
|
|||
'eopayment',
|
||||
'gadjo',
|
||||
'sorl.thumbnail',
|
||||
'combo.data',
|
||||
'combo.profile',
|
||||
'combo.manager',
|
||||
'combo.data.apps.AppConfig',
|
||||
'combo.profile.apps.AppConfig',
|
||||
'combo.manager.apps.AppConfig',
|
||||
'combo.public',
|
||||
'combo.apps.assets',
|
||||
'combo.apps.dashboard',
|
||||
'combo.apps.wcs',
|
||||
'combo.apps.publik',
|
||||
'combo.apps.family',
|
||||
'combo.apps.dataviz',
|
||||
'combo.apps.lingo',
|
||||
'combo.apps.fargo',
|
||||
'combo.apps.notifications',
|
||||
'combo.apps.search',
|
||||
'combo.apps.maps',
|
||||
'combo.apps.calendar',
|
||||
'combo.apps.pwa',
|
||||
'combo.apps.gallery',
|
||||
'combo.apps.kb',
|
||||
'combo.apps.assets.apps.AppConfig',
|
||||
'combo.apps.calendar.apps.AppConfig',
|
||||
'combo.apps.dashboard.apps.AppConfig',
|
||||
'combo.apps.dataviz.apps.AppConfig',
|
||||
'combo.apps.family.apps.AppConfig',
|
||||
'combo.apps.fargo.apps.AppConfig',
|
||||
'combo.apps.gallery.apps.AppConfig',
|
||||
'combo.apps.kb.apps.AppConfig',
|
||||
'combo.apps.lingo.apps.AppConfig',
|
||||
'combo.apps.maps.apps.AppConfig',
|
||||
'combo.apps.notifications.apps.AppConfig',
|
||||
'combo.apps.publik.apps.AppConfig',
|
||||
'combo.apps.pwa.apps.AppConfig',
|
||||
'combo.apps.search.apps.AppConfig',
|
||||
'combo.apps.wcs.apps.AppConfig',
|
||||
'xstatic.pkg.leaflet',
|
||||
'xstatic.pkg.opensans',
|
||||
'xstatic.pkg.roboto_fontface',
|
||||
|
|
|
@ -11,7 +11,7 @@ pytestmark = pytest.mark.django_db
|
|||
|
||||
@override_settings(STATISTICS_PROVIDERS=[])
|
||||
def test_cron_run(app):
|
||||
with mock.patch('combo.apps.lingo.AppConfig.hourly') as hourly_job:
|
||||
with mock.patch('combo.apps.lingo.apps.AppConfig.hourly') as hourly_job:
|
||||
call_command('cron')
|
||||
assert hourly_job.call_count == 1
|
||||
|
||||
|
@ -23,7 +23,7 @@ def test_cron_run(app):
|
|||
|
||||
|
||||
def test_cron_error(app):
|
||||
with mock.patch('combo.apps.lingo.AppConfig.hourly') as hourly_job:
|
||||
with mock.patch('combo.apps.lingo.apps.AppConfig.hourly') as hourly_job:
|
||||
hourly_job.side_effect = Exception('test error')
|
||||
out = StringIO()
|
||||
with pytest.raises(CommandError):
|
||||
|
|
Loading…
Reference in New Issue