0002-django4-fix-default-AppConfig-deprecation-warnings-6.patch
combo/apps/assets/__init__.py | ||
---|---|---|
13 | 13 |
# |
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | ||
17 |
import django.apps |
|
18 |
from django.urls import reverse |
|
19 |
from django.utils.translation import gettext_lazy as _ |
|
20 | ||
21 | ||
22 |
class AppConfig(django.apps.AppConfig): |
|
23 |
name = 'combo.apps.assets' |
|
24 |
verbose_name = _('Assets') |
|
25 | ||
26 |
def get_before_urls(self): |
|
27 |
from . import urls |
|
28 | ||
29 |
return urls.urlpatterns |
|
30 | ||
31 |
def get_extra_manager_actions(self): |
|
32 |
return [{'href': reverse('combo-manager-assets'), 'text': _('Assets')}] |
|
33 | ||
34 | ||
35 |
default_app_config = 'combo.apps.assets.AppConfig' |
combo/apps/assets/apps.py | ||
---|---|---|
1 |
# combo - content management system |
|
2 |
# Copyright (C) 2017-2018 Entr'ouvert |
|
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify it |
|
5 |
# under the terms of the GNU Affero General Public License as published |
|
6 |
# by the Free Software Foundation, either version 3 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU Affero General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU Affero General Public License |
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | ||
17 |
import django.apps |
|
18 |
from django.urls import reverse |
|
19 |
from django.utils.translation import gettext_lazy as _ |
|
20 | ||
21 | ||
22 |
class AppConfig(django.apps.AppConfig): |
|
23 |
name = 'combo.apps.assets' |
|
24 |
verbose_name = _('Assets') |
|
25 | ||
26 |
def get_before_urls(self): |
|
27 |
from . import urls |
|
28 | ||
29 |
return urls.urlpatterns |
|
30 | ||
31 |
def get_extra_manager_actions(self): |
|
32 |
return [{'href': reverse('combo-manager-assets'), 'text': _('Assets')}] |
combo/apps/calendar/__init__.py | ||
---|---|---|
13 | 13 |
# |
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | ||
17 |
import django.apps |
|
18 |
from django.utils.translation import gettext_lazy as _ |
|
19 | ||
20 | ||
21 |
class AppConfig(django.apps.AppConfig): |
|
22 |
name = 'combo.apps.calendar' |
|
23 |
verbose_name = _('Calendar') |
|
24 | ||
25 |
def get_before_urls(self): |
|
26 |
from . import urls |
|
27 | ||
28 |
return urls.urlpatterns |
|
29 | ||
30 | ||
31 |
default_app_config = 'combo.apps.calendar.AppConfig' |
combo/apps/calendar/apps.py | ||
---|---|---|
1 |
# combo - content management system |
|
2 |
# Copyright (C) 2017 Entr'ouvert |
|
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify it |
|
5 |
# under the terms of the GNU Affero General Public License as published |
|
6 |
# by the Free Software Foundation, either version 3 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU Affero General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU Affero General Public License |
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | ||
17 |
import django.apps |
|
18 |
from django.utils.translation import gettext_lazy as _ |
|
19 | ||
20 | ||
21 |
class AppConfig(django.apps.AppConfig): |
|
22 |
name = 'combo.apps.calendar' |
|
23 |
verbose_name = _('Calendar') |
|
24 | ||
25 |
def get_before_urls(self): |
|
26 |
from . import urls |
|
27 | ||
28 |
return urls.urlpatterns |
combo/apps/dashboard/__init__.py | ||
---|---|---|
10 | 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 |
# GNU Affero General Public License for more details. |
13 | ||
14 |
import django.apps |
|
15 |
from django.utils.timezone import now, timedelta |
|
16 |
from django.utils.translation import gettext_lazy as _ |
|
17 | ||
18 | ||
19 |
class AppConfig(django.apps.AppConfig): |
|
20 |
name = 'combo.apps.dashboard' |
|
21 |
verbose_name = _('Dashboard') |
|
22 | ||
23 |
def get_before_urls(self): |
|
24 |
from . import urls |
|
25 | ||
26 |
return urls.urlpatterns |
|
27 | ||
28 |
def hourly(self): |
|
29 |
self.clean_autotiles() |
|
30 | ||
31 |
def clean_autotiles(self): |
|
32 |
from combo.data.models import ConfigJsonCell |
|
33 | ||
34 |
ConfigJsonCell.objects.filter( |
|
35 |
placeholder='_auto_tile', last_update_timestamp__lte=now() - timedelta(days=2) |
|
36 |
).delete() |
|
37 | ||
38 | ||
39 |
default_app_config = 'combo.apps.dashboard.AppConfig' |
combo/apps/dashboard/apps.py | ||
---|---|---|
1 |
# combo - content management system |
|
2 |
# Copyright (C) 2014-2017 Entr'ouvert |
|
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify it |
|
5 |
# under the terms of the GNU Affero General Public License as published |
|
6 |
# by the Free Software Foundation, either version 3 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU Affero General Public License for more details. |
|
13 | ||
14 |
import django.apps |
|
15 |
from django.utils.timezone import now, timedelta |
|
16 |
from django.utils.translation import gettext_lazy as _ |
|
17 | ||
18 | ||
19 |
class AppConfig(django.apps.AppConfig): |
|
20 |
name = 'combo.apps.dashboard' |
|
21 |
verbose_name = _('Dashboard') |
|
22 | ||
23 |
def get_before_urls(self): |
|
24 |
from . import urls |
|
25 | ||
26 |
return urls.urlpatterns |
|
27 | ||
28 |
def hourly(self): |
|
29 |
self.clean_autotiles() |
|
30 | ||
31 |
def clean_autotiles(self): |
|
32 |
from combo.data.models import ConfigJsonCell |
|
33 | ||
34 |
ConfigJsonCell.objects.filter( |
|
35 |
placeholder='_auto_tile', last_update_timestamp__lte=now() - timedelta(days=2) |
|
36 |
).delete() |
combo/apps/dataviz/__init__.py | ||
---|---|---|
13 | 13 |
# |
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | ||
17 |
import django.apps |
|
18 |
from django.utils.translation import gettext_lazy as _ |
|
19 | ||
20 | ||
21 |
class AppConfig(django.apps.AppConfig): |
|
22 |
name = 'combo.apps.dataviz' |
|
23 |
verbose_name = _('Data Visualisation') |
|
24 | ||
25 |
def get_before_urls(self): |
|
26 |
from . import urls |
|
27 | ||
28 |
return urls.urlpatterns |
|
29 | ||
30 |
def hourly(self): |
|
31 |
from .models import ChartNgCell |
|
32 |
from .utils import update_available_statistics |
|
33 | ||
34 |
update_available_statistics() |
|
35 |
for cell in ChartNgCell.objects.all(): |
|
36 |
cell.check_validity() |
|
37 | ||
38 | ||
39 |
default_app_config = 'combo.apps.dataviz.AppConfig' |
combo/apps/dataviz/apps.py | ||
---|---|---|
1 |
# combo - content management system |
|
2 |
# Copyright (C) 2015 Entr'ouvert |
|
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify it |
|
5 |
# under the terms of the GNU Affero General Public License as published |
|
6 |
# by the Free Software Foundation, either version 3 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU Affero General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU Affero General Public License |
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | ||
17 |
import django.apps |
|
18 |
from django.utils.translation import gettext_lazy as _ |
|
19 | ||
20 | ||
21 |
class AppConfig(django.apps.AppConfig): |
|
22 |
name = 'combo.apps.dataviz' |
|
23 |
verbose_name = _('Data Visualisation') |
|
24 | ||
25 |
def get_before_urls(self): |
|
26 |
from . import urls |
|
27 | ||
28 |
return urls.urlpatterns |
|
29 | ||
30 |
def hourly(self): |
|
31 |
from .models import ChartNgCell |
|
32 |
from .utils import update_available_statistics |
|
33 | ||
34 |
update_available_statistics() |
|
35 |
for cell in ChartNgCell.objects.all(): |
|
36 |
cell.check_validity() |
combo/apps/family/__init__.py | ||
---|---|---|
13 | 13 |
# |
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | ||
17 |
import django.apps |
|
18 |
from django.utils.translation import gettext_lazy as _ |
|
19 | ||
20 | ||
21 |
class AppConfig(django.apps.AppConfig): |
|
22 |
name = 'combo.apps.family' |
|
23 |
verbose_name = _('Family') |
|
24 | ||
25 | ||
26 |
default_app_config = 'combo.apps.family.AppConfig' |
combo/apps/family/apps.py | ||
---|---|---|
1 |
# combo - content management system |
|
2 |
# Copyright (C) 2021 Entr'ouvert |
|
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify it |
|
5 |
# under the terms of the GNU Affero General Public License as published |
|
6 |
# by the Free Software Foundation, either version 3 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU Affero General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU Affero General Public License |
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | ||
17 |
import django.apps |
|
18 |
from django.utils.translation import gettext_lazy as _ |
|
19 | ||
20 | ||
21 |
class AppConfig(django.apps.AppConfig): |
|
22 |
name = 'combo.apps.family' |
|
23 |
verbose_name = _('Family') |
combo/apps/fargo/__init__.py | ||
---|---|---|
13 | 13 |
# |
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | ||
17 |
import django.apps |
|
18 |
from django.utils.translation import gettext_lazy as _ |
|
19 | ||
20 | ||
21 |
class AppConfig(django.apps.AppConfig): |
|
22 |
name = 'combo.apps.fargo' |
|
23 |
verbose_name = _('Portfolio') |
|
24 | ||
25 | ||
26 |
default_app_config = 'combo.apps.fargo.AppConfig' |
combo/apps/fargo/apps.py | ||
---|---|---|
1 |
# combo - content management system |
|
2 |
# Copyright (C) 2016 Entr'ouvert |
|
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify it |
|
5 |
# under the terms of the GNU Affero General Public License as published |
|
6 |
# by the Free Software Foundation, either version 3 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU Affero General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU Affero General Public License |
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | ||
17 |
import django.apps |
|
18 |
from django.utils.translation import gettext_lazy as _ |
|
19 | ||
20 | ||
21 |
class AppConfig(django.apps.AppConfig): |
|
22 |
name = 'combo.apps.fargo' |
|
23 |
verbose_name = _('Portfolio') |
combo/apps/gallery/__init__.py | ||
---|---|---|
13 | 13 |
# |
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | ||
17 |
import django.apps |
|
18 |
from django.utils.translation import gettext_lazy as _ |
|
19 | ||
20 | ||
21 |
class AppConfig(django.apps.AppConfig): |
|
22 |
name = 'combo.apps.gallery' |
|
23 |
verbose_name = _('Gallery') |
|
24 | ||
25 |
def get_after_manager_urls(self): |
|
26 |
from . import urls |
|
27 | ||
28 |
return urls.gallery_manager_urls |
|
29 | ||
30 | ||
31 |
default_app_config = 'combo.apps.gallery.AppConfig' |
combo/apps/gallery/apps.py | ||
---|---|---|
1 |
# combo - content management system |
|
2 |
# Copyright (C) 2015 Entr'ouvert |
|
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify it |
|
5 |
# under the terms of the GNU Affero General Public License as published |
|
6 |
# by the Free Software Foundation, either version 3 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU Affero General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU Affero General Public License |
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | ||
17 |
import django.apps |
|
18 |
from django.utils.translation import gettext_lazy as _ |
|
19 | ||
20 | ||
21 |
class AppConfig(django.apps.AppConfig): |
|
22 |
name = 'combo.apps.gallery' |
|
23 |
verbose_name = _('Gallery') |
|
24 | ||
25 |
def get_after_manager_urls(self): |
|
26 |
from . import urls |
|
27 | ||
28 |
return urls.gallery_manager_urls |
combo/apps/kb/__init__.py | ||
---|---|---|
13 | 13 |
# |
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | ||
17 |
import django.apps |
|
18 |
from django.utils.translation import gettext_lazy as _ |
|
19 | ||
20 | ||
21 |
class AppConfig(django.apps.AppConfig): |
|
22 |
name = 'combo.apps.kb' |
|
23 |
verbose_name = _('Knowledge Base') |
|
24 | ||
25 | ||
26 |
default_app_config = 'combo.apps.kb.AppConfig' |
combo/apps/kb/apps.py | ||
---|---|---|
1 |
# combo - content management system |
|
2 |
# Copyright (C) 2020 Entr'ouvert |
|
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify it |
|
5 |
# under the terms of the GNU Affero General Public License as published |
|
6 |
# by the Free Software Foundation, either version 3 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU Affero General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU Affero General Public License |
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | ||
17 |
import django.apps |
|
18 |
from django.utils.translation import gettext_lazy as _ |
|
19 | ||
20 | ||
21 |
class AppConfig(django.apps.AppConfig): |
|
22 |
name = 'combo.apps.kb' |
|
23 |
verbose_name = _('Knowledge Base') |
combo/apps/lingo/__init__.py | ||
---|---|---|
13 | 13 |
# |
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | ||
17 |
import datetime |
|
18 |
import logging |
|
19 | ||
20 |
import django.apps |
|
21 |
import eopayment |
|
22 |
from django.db import transaction |
|
23 |
from django.db.models.signals import post_migrate |
|
24 |
from django.urls import reverse |
|
25 |
from django.utils import timezone |
|
26 |
from django.utils.translation import gettext_lazy as _ |
|
27 | ||
28 | ||
29 |
class AppConfig(django.apps.AppConfig): |
|
30 |
name = 'combo.apps.lingo' |
|
31 |
verbose_name = _('Payment') |
|
32 | ||
33 |
def ready(self): |
|
34 |
post_migrate.connect(self.post_migrate_handler, sender=self) |
|
35 | ||
36 |
def post_migrate_handler(self, **kwargs): |
|
37 |
from .models import PaymentBackend |
|
38 | ||
39 |
with transaction.atomic(): |
|
40 |
for payment_backend in PaymentBackend.objects.all(): |
|
41 |
service_options = payment_backend.service_options |
|
42 |
transaction_options = {} |
|
43 |
for parameter in payment_backend.eopayment.get_parameters(scope='transaction'): |
|
44 |
name = parameter['name'] |
|
45 |
if name in service_options: |
|
46 |
transaction_options[name] = service_options.pop(name) |
|
47 |
if not transaction_options: |
|
48 |
continue |
|
49 |
payment_backend.save() |
|
50 |
for regie in payment_backend.regie_set.all(): |
|
51 |
# merge old values in new transactions options |
|
52 |
regie.transaction_options = dict(transaction_options, **regie.transaction_options) |
|
53 |
regie.save() |
|
54 | ||
55 |
def get_before_urls(self): |
|
56 |
from . import urls |
|
57 | ||
58 |
return urls.urlpatterns |
|
59 | ||
60 |
def get_extra_manager_actions(self): |
|
61 |
return [{'href': reverse('lingo-manager-homepage'), 'text': _('Online Payment')}] |
|
62 | ||
63 |
def hourly(self): |
|
64 |
self.update_transactions() |
|
65 |
self.notify_payments() |
|
66 | ||
67 |
def update_transactions(self): |
|
68 |
from .models import EXPIRED, Transaction |
|
69 | ||
70 |
logger = logging.getLogger(__name__) |
|
71 |
now = timezone.now() |
|
72 |
to_expire = Transaction.objects.filter( |
|
73 |
start_date__lt=now - datetime.timedelta(hours=1), end_date__isnull=True |
|
74 |
) |
|
75 |
for transaction in to_expire: |
|
76 |
logger.info('transaction %r is expired', transaction.order_id) |
|
77 |
transaction.status = EXPIRED |
|
78 |
transaction.save() |
|
79 | ||
80 |
to_retry = Transaction.objects.filter( |
|
81 |
status__in=(eopayment.PAID, eopayment.ACCEPTED), |
|
82 |
to_be_paid_remote_items__isnull=False, |
|
83 |
start_date__gt=now - datetime.timedelta(days=4), |
|
84 |
) |
|
85 |
for transaction in to_retry: |
|
86 |
transaction.retry_notify_remote_items_of_payments() |
|
87 | ||
88 |
def notify_payments(self): |
|
89 |
from combo.apps.lingo.models import BasketItem |
|
90 | ||
91 |
logger = logging.getLogger(__name__) |
|
92 |
now = timezone.now() |
|
93 |
for item in BasketItem.objects.filter( |
|
94 |
notification_date__isnull=True, |
|
95 |
cancellation_date__isnull=True, |
|
96 |
payment_date__lt=now - datetime.timedelta(minutes=5), |
|
97 |
payment_date__gt=now - datetime.timedelta(minutes=300), |
|
98 |
): |
|
99 |
try: |
|
100 |
item.notify_payment() |
|
101 |
except Exception: |
|
102 |
logger.exception('error in async notification for basket item %s', item.id) |
|
103 | ||
104 | ||
105 |
default_app_config = 'combo.apps.lingo.AppConfig' |
combo/apps/lingo/apps.py | ||
---|---|---|
1 |
# lingo - basket and payment system |
|
2 |
# Copyright (C) 2015 Entr'ouvert |
|
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify it |
|
5 |
# under the terms of the GNU Affero General Public License as published |
|
6 |
# by the Free Software Foundation, either version 3 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU Affero General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU Affero General Public License |
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | ||
17 |
import datetime |
|
18 |
import logging |
|
19 | ||
20 |
import django.apps |
|
21 |
import eopayment |
|
22 |
from django.db import transaction |
|
23 |
from django.db.models.signals import post_migrate |
|
24 |
from django.urls import reverse |
|
25 |
from django.utils import timezone |
|
26 |
from django.utils.translation import gettext_lazy as _ |
|
27 | ||
28 | ||
29 |
class AppConfig(django.apps.AppConfig): |
|
30 |
name = 'combo.apps.lingo' |
|
31 |
verbose_name = _('Payment') |
|
32 | ||
33 |
def ready(self): |
|
34 |
post_migrate.connect(self.post_migrate_handler, sender=self) |
|
35 | ||
36 |
def post_migrate_handler(self, **kwargs): |
|
37 |
from .models import PaymentBackend |
|
38 | ||
39 |
with transaction.atomic(): |
|
40 |
for payment_backend in PaymentBackend.objects.all(): |
|
41 |
service_options = payment_backend.service_options |
|
42 |
transaction_options = {} |
|
43 |
for parameter in payment_backend.eopayment.get_parameters(scope='transaction'): |
|
44 |
name = parameter['name'] |
|
45 |
if name in service_options: |
|
46 |
transaction_options[name] = service_options.pop(name) |
|
47 |
if not transaction_options: |
|
48 |
continue |
|
49 |
payment_backend.save() |
|
50 |
for regie in payment_backend.regie_set.all(): |
|
51 |
# merge old values in new transactions options |
|
52 |
regie.transaction_options = dict(transaction_options, **regie.transaction_options) |
|
53 |
regie.save() |
|
54 | ||
55 |
def get_before_urls(self): |
|
56 |
from . import urls |
|
57 | ||
58 |
return urls.urlpatterns |
|
59 | ||
60 |
def get_extra_manager_actions(self): |
|
61 |
return [{'href': reverse('lingo-manager-homepage'), 'text': _('Online Payment')}] |
|
62 | ||
63 |
def hourly(self): |
|
64 |
self.update_transactions() |
|
65 |
self.notify_payments() |
|
66 | ||
67 |
def update_transactions(self): |
|
68 |
from .models import EXPIRED, Transaction |
|
69 | ||
70 |
logger = logging.getLogger(__name__) |
|
71 |
now = timezone.now() |
|
72 |
to_expire = Transaction.objects.filter( |
|
73 |
start_date__lt=now - datetime.timedelta(hours=1), end_date__isnull=True |
|
74 |
) |
|
75 |
for transaction in to_expire: |
|
76 |
logger.info('transaction %r is expired', transaction.order_id) |
|
77 |
transaction.status = EXPIRED |
|
78 |
transaction.save() |
|
79 | ||
80 |
to_retry = Transaction.objects.filter( |
|
81 |
status__in=(eopayment.PAID, eopayment.ACCEPTED), |
|
82 |
to_be_paid_remote_items__isnull=False, |
|
83 |
start_date__gt=now - datetime.timedelta(days=4), |
|
84 |
) |
|
85 |
for transaction in to_retry: |
|
86 |
transaction.retry_notify_remote_items_of_payments() |
|
87 | ||
88 |
def notify_payments(self): |
|
89 |
from combo.apps.lingo.models import BasketItem |
|
90 | ||
91 |
logger = logging.getLogger(__name__) |
|
92 |
now = timezone.now() |
|
93 |
for item in BasketItem.objects.filter( |
|
94 |
notification_date__isnull=True, |
|
95 |
cancellation_date__isnull=True, |
|
96 |
payment_date__lt=now - datetime.timedelta(minutes=5), |
|
97 |
payment_date__gt=now - datetime.timedelta(minutes=300), |
|
98 |
): |
|
99 |
try: |
|
100 |
item.notify_payment() |
|
101 |
except Exception: |
|
102 |
logger.exception('error in async notification for basket item %s', item.id) |
combo/apps/maps/__init__.py | ||
---|---|---|
13 | 13 |
# |
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | ||
17 |
import django.apps |
|
18 |
from django.urls import reverse |
|
19 |
from django.utils.translation import gettext_lazy as _ |
|
20 | ||
21 | ||
22 |
class AppConfig(django.apps.AppConfig): |
|
23 |
name = 'combo.apps.maps' |
|
24 |
verbose_name = _('Maps') |
|
25 | ||
26 |
def get_before_urls(self): |
|
27 |
from . import urls |
|
28 | ||
29 |
return urls.urlpatterns |
|
30 | ||
31 |
def get_extra_manager_actions(self): |
|
32 |
return [{'href': reverse('maps-manager-homepage'), 'text': _('Maps')}] |
|
33 | ||
34 | ||
35 |
default_app_config = 'combo.apps.maps.AppConfig' |
combo/apps/maps/apps.py | ||
---|---|---|
1 |
# combo - content management system |
|
2 |
# Copyright (C) 2017 Entr'ouvert |
|
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify it |
|
5 |
# under the terms of the GNU Affero General Public License as published |
|
6 |
# by the Free Software Foundation, either version 3 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU Affero General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU Affero General Public License |
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | ||
17 |
import django.apps |
|
18 |
from django.urls import reverse |
|
19 |
from django.utils.translation import gettext_lazy as _ |
|
20 | ||
21 | ||
22 |
class AppConfig(django.apps.AppConfig): |
|
23 |
name = 'combo.apps.maps' |
|
24 |
verbose_name = _('Maps') |
|
25 | ||
26 |
def get_before_urls(self): |
|
27 |
from . import urls |
|
28 | ||
29 |
return urls.urlpatterns |
|
30 | ||
31 |
def get_extra_manager_actions(self): |
|
32 |
return [{'href': reverse('maps-manager-homepage'), 'text': _('Maps')}] |
combo/apps/notifications/__init__.py | ||
---|---|---|
13 | 13 |
# |
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | ||
17 |
import django.apps |
|
18 |
from django.utils.translation import gettext_lazy as _ |
|
19 | ||
20 | ||
21 |
class AppConfig(django.apps.AppConfig): |
|
22 |
name = 'combo.apps.notifications' |
|
23 |
verbose_name = _('Notification') |
|
24 | ||
25 |
def get_before_urls(self): |
|
26 |
from . import urls |
|
27 | ||
28 |
return urls.urlpatterns |
|
29 | ||
30 | ||
31 |
default_app_config = 'combo.apps.notifications.AppConfig' |
combo/apps/notifications/apps.py | ||
---|---|---|
1 |
# combo - content management system |
|
2 |
# Copyright (C) 2016 Entr'ouvert |
|
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify it |
|
5 |
# under the terms of the GNU Affero General Public License as published |
|
6 |
# by the Free Software Foundation, either version 3 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU Affero General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU Affero General Public License |
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | ||
17 |
import django.apps |
|
18 |
from django.utils.translation import gettext_lazy as _ |
|
19 | ||
20 | ||
21 |
class AppConfig(django.apps.AppConfig): |
|
22 |
name = 'combo.apps.notifications' |
|
23 |
verbose_name = _('Notification') |
|
24 | ||
25 |
def get_before_urls(self): |
|
26 |
from . import urls |
|
27 | ||
28 |
return urls.urlpatterns |
|
29 | ||
30 | ||
31 |
default_app_config = 'combo.apps.notifications.AppConfig' |
combo/apps/publik/__init__.py | ||
---|---|---|
13 | 13 |
# |
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | ||
17 |
import django.apps |
|
18 | ||
19 | ||
20 |
class AppConfig(django.apps.AppConfig): |
|
21 |
name = 'combo.apps.publik' |
|
22 | ||
23 |
def get_before_urls(self): |
|
24 |
from . import urls |
|
25 | ||
26 |
return urls.urlpatterns |
|
27 | ||
28 | ||
29 |
default_app_config = 'combo.apps.publik.AppConfig' |
combo/apps/publik/apps.py | ||
---|---|---|
1 |
# combo - content management system |
|
2 |
# Copyright (C) 2015 Entr'ouvert |
|
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify it |
|
5 |
# under the terms of the GNU Affero General Public License as published |
|
6 |
# by the Free Software Foundation, either version 3 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU Affero General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU Affero General Public License |
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | ||
17 |
import django.apps |
|
18 | ||
19 | ||
20 |
class AppConfig(django.apps.AppConfig): |
|
21 |
name = 'combo.apps.publik' |
|
22 | ||
23 |
def get_before_urls(self): |
|
24 |
from . import urls |
|
25 | ||
26 |
return urls.urlpatterns |
combo/apps/pwa/__init__.py | ||
---|---|---|
13 | 13 |
# |
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | ||
17 |
import django.apps |
|
18 |
from django.urls import reverse |
|
19 |
from django.utils.translation import gettext_lazy as _ |
|
20 | ||
21 | ||
22 |
class AppConfig(django.apps.AppConfig): |
|
23 |
name = 'combo.apps.pwa' |
|
24 | ||
25 |
def ready(self): |
|
26 |
from . import signals # noqa pylint: disable=unused-import |
|
27 | ||
28 |
def get_before_urls(self): |
|
29 |
from . import urls |
|
30 | ||
31 |
return urls.urlpatterns |
|
32 | ||
33 |
def get_extra_manager_actions(self): |
|
34 |
from django.conf import settings |
|
35 | ||
36 |
if settings.TEMPLATE_VARS.get('pwa_display') == 'standalone': |
|
37 |
return [{'href': reverse('pwa-manager-homepage'), 'text': _('Mobile Application (PWA)')}] |
|
38 |
return [] |
|
39 | ||
40 | ||
41 |
default_app_config = 'combo.apps.pwa.AppConfig' |
combo/apps/pwa/apps.py | ||
---|---|---|
1 |
# combo - content management system |
|
2 |
# Copyright (C) 2015-2018 Entr'ouvert |
|
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify it |
|
5 |
# under the terms of the GNU Affero General Public License as published |
|
6 |
# by the Free Software Foundation, either version 3 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU Affero General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU Affero General Public License |
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | ||
17 |
import django.apps |
|
18 |
from django.urls import reverse |
|
19 |
from django.utils.translation import gettext_lazy as _ |
|
20 | ||
21 | ||
22 |
class AppConfig(django.apps.AppConfig): |
|
23 |
name = 'combo.apps.pwa' |
|
24 | ||
25 |
def ready(self): |
|
26 |
from . import signals # noqa pylint: disable=unused-import |
|
27 | ||
28 |
def get_before_urls(self): |
|
29 |
from . import urls |
|
30 | ||
31 |
return urls.urlpatterns |
|
32 | ||
33 |
def get_extra_manager_actions(self): |
|
34 |
from django.conf import settings |
|
35 | ||
36 |
if settings.TEMPLATE_VARS.get('pwa_display') == 'standalone': |
|
37 |
return [{'href': reverse('pwa-manager-homepage'), 'text': _('Mobile Application (PWA)')}] |
|
38 |
return [] |
combo/apps/search/__init__.py | ||
---|---|---|
12 | 12 |
# GNU Affero General Public License for more details. |
13 | 13 |
# |
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | ||
17 |
import django.apps |
|
18 |
from django.urls import reverse |
|
19 |
from django.utils.translation import gettext_lazy as _ |
|
20 | ||
15 |
# along with this program. If not, see <http://www. |
|
21 | 16 |
from .engines import engines |
22 | ||
23 | ||
24 |
class AppConfig(django.apps.AppConfig): |
|
25 |
name = 'combo.apps.search' |
|
26 |
verbose_name = _('Search') |
|
27 | ||
28 |
def get_before_urls(self): |
|
29 |
from . import urls |
|
30 | ||
31 |
return urls.urlpatterns |
|
32 | ||
33 |
def hourly(self): |
|
34 |
from .utils import index_site |
|
35 | ||
36 |
index_site() |
|
37 | ||
38 |
def ready(self): |
|
39 |
# register built-in search engine for page contents |
|
40 |
engines.register(self.get_search_engines) |
|
41 | ||
42 |
def get_search_engines(self): |
|
43 |
from .utils import search_site |
|
44 | ||
45 |
return { |
|
46 |
'_text': { |
|
47 |
'function': search_site, |
|
48 |
'label': _('Page Contents'), |
|
49 |
} |
|
50 |
} |
|
51 | ||
52 | ||
53 |
default_app_config = 'combo.apps.search.AppConfig' |
combo/apps/search/apps.py | ||
---|---|---|
1 |
# combo - content management system |
|
2 |
# Copyright (C) 2014-2017 Entr'ouvert |
|
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify it |
|
5 |
# under the terms of the GNU Affero General Public License as published |
|
6 |
# by the Free Software Foundation, either version 3 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU Affero General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU Affero General Public License |
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | ||
17 |
import django.apps |
|
18 |
from django.utils.translation import gettext_lazy as _ |
|
19 | ||
20 |
from .engines import engines |
|
21 | ||
22 | ||
23 |
class AppConfig(django.apps.AppConfig): |
|
24 |
name = 'combo.apps.search' |
|
25 |
verbose_name = _('Search') |
|
26 | ||
27 |
def get_before_urls(self): |
|
28 |
from . import urls |
|
29 | ||
30 |
return urls.urlpatterns |
|
31 | ||
32 |
def hourly(self): |
|
33 |
from .utils import index_site |
|
34 | ||
35 |
index_site() |
|
36 | ||
37 |
def ready(self): |
|
38 |
# register built-in search engine for page contents |
|
39 |
engines.register(self.get_search_engines) |
|
40 | ||
41 |
def get_search_engines(self): |
|
42 |
from .utils import search_site |
|
43 | ||
44 |
return { |
|
45 |
'_text': { |
|
46 |
'function': search_site, |
|
47 |
'label': _('Page Contents'), |
|
48 |
} |
|
49 |
} |
combo/apps/wcs/__init__.py | ||
---|---|---|
13 | 13 |
# |
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | ||
17 |
import hashlib |
|
18 | ||
19 |
import django.apps |
|
20 |
from django.conf import settings |
|
21 |
from django.urls import reverse |
|
22 |
from django.utils.encoding import force_bytes |
|
23 |
from django.utils.translation import gettext_lazy as _ |
|
24 |
from django.utils.translation import pgettext_lazy |
|
25 | ||
26 | ||
27 |
class AppConfig(django.apps.AppConfig): |
|
28 |
name = 'combo.apps.wcs' |
|
29 |
verbose_name = _('Forms') |
|
30 | ||
31 |
def ready(self): |
|
32 |
from combo.apps.search import engines |
|
33 | ||
34 |
engines.register(self.get_search_engines) |
|
35 | ||
36 |
def get_search_engines(self): |
|
37 |
from .utils import get_wcs_services |
|
38 | ||
39 |
wcs_services = get_wcs_services() |
|
40 |
if not wcs_services: |
|
41 |
return |
|
42 | ||
43 |
engines = self.get_portal_agent_search_engines(wcs_services) |
|
44 |
engines.update(self.get_card_search_engines(wcs_services)) |
|
45 | ||
46 |
return engines |
|
47 | ||
48 |
def get_card_search_engines(self, wcs_services): |
|
49 |
from combo.data.models import Page |
|
50 | ||
51 |
from .utils import get_wcs_json |
|
52 | ||
53 |
pages_with_sub_slug = Page.objects.exclude(sub_slug='') |
|
54 |
if not pages_with_sub_slug: |
|
55 |
return {} |
|
56 | ||
57 |
engines = {} |
|
58 |
for key, service in wcs_services.items(): |
|
59 |
card_models = get_wcs_json(service, 'api/cards/@list') |
|
60 |
for card in card_models.get('data') or []: |
|
61 |
card_id = '%s_id' % card['id'] |
|
62 |
matching_pages = [ |
|
63 |
p for p in pages_with_sub_slug if '<%s>' % card_id in p.sub_slug or p.sub_slug == card_id |
|
64 |
] |
|
65 |
if not matching_pages: |
|
66 |
continue |
|
67 |
card_page = matching_pages[0] |
|
68 |
card_page_base_url = card_page.get_online_url() |
|
69 |
label = card['text'] |
|
70 |
if len(wcs_services.keys()) > 1: |
|
71 |
label = '%s (%s)' % (label, service['title']) |
|
72 |
engines['cards:%s:%s' % (hashlib.md5(force_bytes(key)).hexdigest()[:8], card['id'])] = { |
|
73 |
'url': ( |
|
74 |
service['url'] + 'api/cards/' + card['id'] + '/list/' |
|
75 |
'{% if search_service.selected_custom_view %}{{ search_service.selected_custom_view }}{% endif %}' |
|
76 |
'?{% if not search_service.without_user %}NameID={{ user_nameid }}&{% endif %}' |
|
77 |
'q=%(q)s' |
|
78 |
), |
|
79 |
'custom_views': card.get('custom_views') or [], |
|
80 |
'label': label, |
|
81 |
'signature': True, |
|
82 |
'hit_url_template': card_page_base_url + '{{ id }}', |
|
83 |
'hit_label_template': '{% firstof digest text %}', |
|
84 |
} |
|
85 |
return engines |
|
86 | ||
87 |
def get_portal_agent_search_engines(self, wcs_services): |
|
88 |
if not settings.TEMPLATE_VARS.get('is_portal_agent'): |
|
89 |
return {} |
|
90 | ||
91 |
engines = { |
|
92 |
'tracking-code': { |
|
93 |
'url': reverse('wcs-tracking-code-search') + '?q=%(q)s', |
|
94 |
'label': _('Tracking Code'), |
|
95 |
} |
|
96 |
} |
|
97 |
for key, service in wcs_services.items(): |
|
98 |
label = pgettext_lazy('user-forms', 'Forms') |
|
99 |
if len(wcs_services.keys()) > 1: |
|
100 |
label = pgettext_lazy('user-forms', 'Forms (%s)') % service['title'] |
|
101 |
engines['formdata:%s' % hashlib.md5(force_bytes(key)).hexdigest()[:8]] = { |
|
102 |
'url': service['url'] |
|
103 |
+ 'api/forms/?NameID={{user_nameid}}&status=all&ignore-roles=on&include-anonymised=off&q=%(q)s', |
|
104 |
'label': label, |
|
105 |
'signature': True, |
|
106 |
'hit_url_template': '{% if readable %}{{ form_url_backoffice }}{% endif %}', |
|
107 |
'hit_label_template': '{{ title }}', |
|
108 |
'hit_description_template': '{{ form_digest|default:"" }}', |
|
109 |
} |
|
110 |
return engines |
|
111 | ||
112 |
def get_before_urls(self): |
|
113 |
from . import urls |
|
114 | ||
115 |
return urls.urlpatterns |
|
116 | ||
117 |
def hourly(self): |
|
118 |
from combo.data.library import get_cell_classes |
|
119 |
from combo.data.models import CellBase |
|
120 | ||
121 |
cell_classes = [c for c in self.get_models() if c in get_cell_classes()] |
|
122 |
for cell in CellBase.get_cells(cell_filter=lambda x: x in cell_classes, page__snapshot__isnull=True): |
|
123 |
if hasattr(cell, 'check_validity'): |
|
124 |
cell.check_validity() |
|
125 | ||
126 |
self.update_db_cache() |
|
127 | ||
128 |
def update_db_cache(self): |
|
129 |
from combo.data.models import CellBase |
|
130 | ||
131 |
from .models import WcsCardCell, WcsCategoryCell, WcsFormCell, WcsFormsOfCategoryCell |
|
132 | ||
133 |
models_to_update = [ |
|
134 |
WcsFormCell, |
|
135 |
WcsCategoryCell, |
|
136 |
WcsFormsOfCategoryCell, |
|
137 |
WcsCardCell, |
|
138 |
] |
|
139 |
for cell in CellBase.get_cells(cell_filter=lambda x: x in models_to_update): |
|
140 |
cell.save() |
|
141 | ||
142 | ||
143 |
default_app_config = 'combo.apps.wcs.AppConfig' |
combo/apps/wcs/apps.py | ||
---|---|---|
1 |
# combo - content management system |
|
2 |
# Copyright (C) 2016 Entr'ouvert |
|
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify it |
|
5 |
# under the terms of the GNU Affero General Public License as published |
|
6 |
# by the Free Software Foundation, either version 3 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU Affero General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU Affero General Public License |
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | ||
17 |
import hashlib |
|
18 | ||
19 |
import django.apps |
|
20 |
from django.conf import settings |
|
21 |
from django.urls import reverse |
|
22 |
from django.utils.encoding import force_bytes |
|
23 |
from django.utils.translation import gettext_lazy as _ |
|
24 |
from django.utils.translation import pgettext_lazy |
|
25 | ||
26 | ||
27 |
class AppConfig(django.apps.AppConfig): |
|
28 |
name = 'combo.apps.wcs' |
|
29 |
verbose_name = _('Forms') |
|
30 | ||
31 |
def ready(self): |
|
32 |
from combo.apps.search import engines |
|
33 | ||
34 |
engines.register(self.get_search_engines) |
|
35 | ||
36 |
def get_search_engines(self): |
|
37 |
from .utils import get_wcs_services |
|
38 | ||
39 |
wcs_services = get_wcs_services() |
|
40 |
if not wcs_services: |
|
41 |
return |
|
42 | ||
43 |
engines = self.get_portal_agent_search_engines(wcs_services) |
|
44 |
engines.update(self.get_card_search_engines(wcs_services)) |
|
45 | ||
46 |
return engines |
|
47 | ||
48 |
def get_card_search_engines(self, wcs_services): |
|
49 |
from combo.data.models import Page |
|
50 | ||
51 |
from .utils import get_wcs_json |
|
52 | ||
53 |
pages_with_sub_slug = Page.objects.exclude(sub_slug='') |
|
54 |
if not pages_with_sub_slug: |
|
55 |
return {} |
|
56 | ||
57 |
engines = {} |
|
58 |
for key, service in wcs_services.items(): |
|
59 |
card_models = get_wcs_json(service, 'api/cards/@list') |
|
60 |
for card in card_models.get('data') or []: |
|
61 |
card_id = '%s_id' % card['id'] |
|
62 |
matching_pages = [ |
|
63 |
p for p in pages_with_sub_slug if '<%s>' % card_id in p.sub_slug or p.sub_slug == card_id |
|
64 |
] |
|
65 |
if not matching_pages: |
|
66 |
continue |
|
67 |
card_page = matching_pages[0] |
|
68 |
card_page_base_url = card_page.get_online_url() |
|
69 |
label = card['text'] |
|
70 |
if len(wcs_services.keys()) > 1: |
|
71 |
label = '%s (%s)' % (label, service['title']) |
|
72 |
engines['cards:%s:%s' % (hashlib.md5(force_bytes(key)).hexdigest()[:8], card['id'])] = { |
|
73 |
'url': ( |
|
74 |
service['url'] + 'api/cards/' + card['id'] + '/list/' |
|
75 |
'{% if search_service.selected_custom_view %}{{ search_service.selected_custom_view }}{% endif %}' |
|
76 |
'?{% if not search_service.without_user %}NameID={{ user_nameid }}&{% endif %}' |
|
77 |
'q=%(q)s' |
|
78 |
), |
|
79 |
'custom_views': card.get('custom_views') or [], |
|
80 |
'label': label, |
|
81 |
'signature': True, |
|
82 |
'hit_url_template': card_page_base_url + '{{ id }}', |
|
83 |
'hit_label_template': '{% firstof digest text %}', |
|
84 |
} |
|
85 |
return engines |
|
86 | ||
87 |
def get_portal_agent_search_engines(self, wcs_services): |
|
88 |
if not settings.TEMPLATE_VARS.get('is_portal_agent'): |
|
89 |
return {} |
|
90 | ||
91 |
engines = { |
|
92 |
'tracking-code': { |
|
93 |
'url': reverse('wcs-tracking-code-search') + '?q=%(q)s', |
|
94 |
'label': _('Tracking Code'), |
|
95 |
} |
|
96 |
} |
|
97 |
for key, service in wcs_services.items(): |
|
98 |
label = pgettext_lazy('user-forms', 'Forms') |
|
99 |
if len(wcs_services.keys()) > 1: |
|
100 |
label = pgettext_lazy('user-forms', 'Forms (%s)') % service['title'] |
|
101 |
engines['formdata:%s' % hashlib.md5(force_bytes(key)).hexdigest()[:8]] = { |
|
102 |
'url': service['url'] |
|
103 |
+ 'api/forms/?NameID={{user_nameid}}&status=all&ignore-roles=on&include-anonymised=off&q=%(q)s', |
|
104 |
'label': label, |
|
105 |
'signature': True, |
|
106 |
'hit_url_template': '{% if readable %}{{ form_url_backoffice }}{% endif %}', |
|
107 |
'hit_label_template': '{{ title }}', |
|
108 |
'hit_description_template': '{{ form_digest|default:"" }}', |
|
109 |
} |
|
110 |
return engines |
|
111 | ||
112 |
def get_before_urls(self): |
|
113 |
from . import urls |
|
114 | ||
115 |
return urls.urlpatterns |
|
116 | ||
117 |
def hourly(self): |
|
118 |
from combo.data.library import get_cell_classes |
|
119 |
from combo.data.models import CellBase |
|
120 | ||
121 |
cell_classes = [c for c in self.get_models() if c in get_cell_classes()] |
|
122 |
for cell in CellBase.get_cells(cell_filter=lambda x: x in cell_classes, page__snapshot__isnull=True): |
|
123 |
if hasattr(cell, 'check_validity'): |
|
124 |
cell.check_validity() |
|
125 | ||
126 |
self.update_db_cache() |
|
127 | ||
128 |
def update_db_cache(self): |
|
129 |
from combo.data.models import CellBase |
|
130 | ||
131 |
from .models import WcsCardCell, WcsCategoryCell, WcsFormCell, WcsFormsOfCategoryCell |
|
132 | ||
133 |
models_to_update = [ |
|
134 |
WcsFormCell, |
|
135 |
WcsCategoryCell, |
|
136 |
WcsFormsOfCategoryCell, |
|
137 |
WcsCardCell, |
|
138 |
] |
|
139 |
for cell in CellBase.get_cells(cell_filter=lambda x: x in models_to_update): |
|
140 |
cell.save() |
combo/data/__init__.py | ||
---|---|---|
1 |
default_app_config = 'combo.data.apps.DataConfig' |
combo/data/apps.py | ||
---|---|---|
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 |
from django.apps import AppConfig |
|
17 |
import django.apps |
|
18 | 18 | |
19 | 19 | |
20 |
class DataConfig(AppConfig):
|
|
20 |
class AppConfig(django.apps.AppConfig):
|
|
21 | 21 |
name = 'combo.data' |
22 | 22 |
verbose_name = 'data' |
23 | 23 |
combo/data/utils.py | ||
---|---|---|
49 | 49 |
def export_site(pages=True, cartography=True, pwa=True, assets=True, payment=True, site_settings=True): |
50 | 50 |
'''Dump site objects to JSON-dumpable dictionnary''' |
51 | 51 | |
52 |
if 'combo.apps.lingo' in settings.INSTALLED_APPS: |
|
52 |
if 'combo.apps.lingo.apps.AppConfig' in settings.INSTALLED_APPS:
|
|
53 | 53 |
from combo.apps.lingo.models import PaymentBackend, Regie |
54 | 54 |
else: |
55 | 55 |
payment = False |
56 | 56 | |
57 |
if 'combo.apps.maps' in settings.INSTALLED_APPS: |
|
57 |
if 'combo.apps.maps.apps.AppConfig' in settings.INSTALLED_APPS:
|
|
58 | 58 |
from combo.apps.maps.models import MapLayer |
59 | 59 |
else: |
60 | 60 |
cartography = False |
61 | 61 | |
62 |
if 'combo.apps.pwa' in settings.INSTALLED_APPS: |
|
62 |
if 'combo.apps.pwa.apps.AppConfig' in settings.INSTALLED_APPS:
|
|
63 | 63 |
from combo.apps.pwa.models import PwaNavigationEntry, PwaSettings |
64 | 64 |
else: |
65 | 65 |
pwa = False |
... | ... | |
92 | 92 |
# format. |
93 | 93 |
data = {'pages': data} |
94 | 94 | |
95 |
if 'combo.apps.lingo' in settings.INSTALLED_APPS: |
|
95 |
if 'combo.apps.lingo.apps.AppConfig' in settings.INSTALLED_APPS:
|
|
96 | 96 |
from combo.apps.lingo.models import PaymentBackend, Regie |
97 | 97 | |
98 | 98 |
payment_support = True |
99 | 99 |
else: |
100 | 100 |
payment_support = False |
101 | 101 | |
102 |
if 'combo.apps.maps' in settings.INSTALLED_APPS: |
|
102 |
if 'combo.apps.maps.apps.AppConfig' in settings.INSTALLED_APPS:
|
|
103 | 103 |
from combo.apps.maps.models import MapLayer |
104 | 104 | |
105 | 105 |
cartography_support = True |
106 | 106 |
else: |
107 | 107 |
cartography_support = False |
108 | 108 | |
109 |
if 'combo.apps.pwa' in settings.INSTALLED_APPS: |
|
109 |
if 'combo.apps.pwa.apps.AppConfig' in settings.INSTALLED_APPS:
|
|
110 | 110 |
from combo.apps.pwa.models import PwaNavigationEntry, PwaSettings |
111 | 111 | |
112 | 112 |
pwa_support = True |
... | ... | |
185 | 185 |
except KeyError: |
186 | 186 |
raise ImportSiteError(_('TAR file should provide _site.json file')) |
187 | 187 | |
188 |
if 'combo.apps.maps' in settings.INSTALLED_APPS: |
|
188 |
if 'combo.apps.maps.apps.AppConfig' in settings.INSTALLED_APPS:
|
|
189 | 189 |
from combo.apps.maps.models import MapLayer |
190 | 190 | |
191 | 191 |
cartography_support = True |
combo/manager/__init__.py | ||
---|---|---|
13 | 13 |
# |
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | ||
17 |
default_app_config = 'combo.manager.apps.ManagerAppConfig' |
combo/manager/apps.py | ||
---|---|---|
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 |
from django.apps import AppConfig |
|
17 |
import django.apps |
|
18 | 18 | |
19 | 19 | |
20 |
class ManagerAppConfig(AppConfig):
|
|
20 |
class AppConfig(django.apps.AppConfig):
|
|
21 | 21 |
name = 'combo.manager' |
22 | 22 | |
23 | 23 |
def ready(self): |
combo/profile/__init__.py | ||
---|---|---|
16 | 16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | |
18 | 18 | |
19 |
import django.apps |
|
20 |
from django.utils.translation import gettext_lazy as _ |
|
21 | ||
22 | ||
23 | 19 |
def user_get_name_id(user): |
24 | 20 |
if not hasattr(user, '_name_id'): |
25 | 21 |
user._name_id = None |
... | ... | |
37 | 33 |
{% if address %} {{ address }}{% endif %} |
38 | 34 |
{% if zipcode %} {{ zipcode }}{% endif %} |
39 | 35 |
{% if city %} {{ city }}{% endif %}""" |
40 | ||
41 | ||
42 |
class AppConfig(django.apps.AppConfig): |
|
43 |
name = 'combo.profile' |
|
44 |
verbose_name = _('Profile') |
|
45 | ||
46 |
def ready(self): |
|
47 |
from combo.apps.search import engines |
|
48 | ||
49 |
engines.register(self.get_search_engines) |
|
50 |
from django.contrib.auth import get_user_model |
|
51 | ||
52 |
get_user_model().add_to_class('get_name_id', user_get_name_id) |
|
53 | ||
54 |
def get_search_engines(self): |
|
55 |
from django.conf import settings |
|
56 | ||
57 |
from combo.data.models import Page |
|
58 | ||
59 |
user_page = Page.objects.filter(sub_slug='name_id').first() |
|
60 |
if not user_page: |
|
61 |
user_page = Page.objects.filter(sub_slug__contains='<name_id>').first() |
|
62 |
if not user_page: |
|
63 |
return |
|
64 |
user_page_base_url = user_page.get_online_url() |
|
65 | ||
66 |
# return entry using first(&only) authentic (if it exists) |
|
67 |
for service in settings.KNOWN_SERVICES.get('authentic', {}).values(): |
|
68 |
return { |
|
69 |
'users': { |
|
70 |
'url': service['url'] + 'api/users/?q=%(q)s', |
|
71 |
'label': _('Users'), |
|
72 |
'signature': True, |
|
73 |
'data_key': 'results', |
|
74 |
'hit_url_template': user_page_base_url + '{{uuid}}/', |
|
75 |
'hit_label_template': '{{first_name}} {{last_name}}', |
|
76 |
'hit_description_template': default_description_template, |
|
77 |
} |
|
78 |
} |
|
79 | ||
80 | ||
81 |
default_app_config = 'combo.profile.AppConfig' |
combo/profile/apps.py | ||
---|---|---|
1 |
import django.apps |
|
2 |
from django.utils.translation import gettext_lazy as _ |
|
3 | ||
4 |
from . import default_description_template, user_get_name_id |
|
5 | ||
6 | ||
7 |
class AppConfig(django.apps.AppConfig): |
|
8 |
name = 'combo.profile' |
|
9 |
verbose_name = _('Profile') |
|
10 | ||
11 |
def ready(self): |
|
12 |
from combo.apps.search import engines |
|
13 | ||
14 |
engines.register(self.get_search_engines) |
|
15 |
from django.contrib.auth import get_user_model |
|
16 | ||
17 |
get_user_model().add_to_class('get_name_id', user_get_name_id) |
|
18 | ||
19 |
def get_search_engines(self): |
|
20 |
from django.conf import settings |
|
21 | ||
22 |
from combo.data.models import Page |
|
23 | ||
24 |
user_page = Page.objects.filter(sub_slug='name_id').first() |
|
25 |
if not user_page: |
|
26 |
user_page = Page.objects.filter(sub_slug__contains='<name_id>').first() |
|
27 |
if not user_page: |
|
28 |
return |
|
29 |
user_page_base_url = user_page.get_online_url() |
|
30 | ||
31 |
# return entry using first(&only) authentic (if it exists) |
|
32 |
for service in settings.KNOWN_SERVICES.get('authentic', {}).values(): |
|
33 |
return { |
|
34 |
'users': { |
|
35 |
'url': service['url'] + 'api/users/?q=%(q)s', |
|
36 |
'label': _('Users'), |
|
37 |
'signature': True, |
|
38 |
'data_key': 'results', |
|
39 |
'hit_url_template': user_page_base_url + '{{uuid}}/', |
|
40 |
'hit_label_template': '{{first_name}} {{last_name}}', |
|
41 |
'hit_description_template': default_description_template, |
|
42 |
} |
|
43 |
} |
combo/settings.py | ||
---|---|---|
59 | 59 |
'eopayment', |
60 | 60 |
'gadjo', |
61 | 61 |
'sorl.thumbnail', |
62 |
'combo.data', |
|
63 |
'combo.profile', |
|
64 |
'combo.manager', |
|
62 |
'combo.data.apps.AppConfig',
|
|
63 |
'combo.profile.apps.AppConfig',
|
|
64 |
'combo.manager.apps.AppConfig',
|
|
65 | 65 |
'combo.public', |
66 |
'combo.apps.assets', |
|
67 |
'combo.apps.dashboard',
|
|
68 |
'combo.apps.wcs',
|
|
69 |
'combo.apps.publik',
|
|
70 |
'combo.apps.family', |
|
71 |
'combo.apps.dataviz',
|
|
72 |
'combo.apps.lingo',
|
|
73 |
'combo.apps.fargo',
|
|
74 |
'combo.apps.notifications',
|
|
75 |
'combo.apps.search',
|
|
76 |
'combo.apps.maps',
|
|
77 |
'combo.apps.calendar',
|
|
78 |
'combo.apps.pwa', |
|
79 |
'combo.apps.gallery',
|
|
80 |
'combo.apps.kb',
|
|
66 |
'combo.apps.assets.apps.AppConfig',
|
|
67 |
'combo.apps.calendar.apps.AppConfig',
|
|
68 |
'combo.apps.dashboard.apps.AppConfig',
|
|
69 |
'combo.apps.dataviz.apps.AppConfig',
|
|
70 |
'combo.apps.family.apps.AppConfig',
|
|
71 |
'combo.apps.fargo.apps.AppConfig',
|
|
72 |
'combo.apps.gallery.apps.AppConfig',
|
|
73 |
'combo.apps.kb.apps.AppConfig',
|
|
74 |
'combo.apps.lingo.apps.AppConfig',
|
|
75 |
'combo.apps.maps.apps.AppConfig',
|
|
76 |
'combo.apps.notifications.apps.AppConfig',
|
|
77 |
'combo.apps.publik.apps.AppConfig',
|
|
78 |
'combo.apps.pwa.apps.AppConfig',
|
|
79 |
'combo.apps.search.apps.AppConfig',
|
|
80 |
'combo.apps.wcs.apps.AppConfig',
|
|
81 | 81 |
'xstatic.pkg.leaflet', |
82 | 82 |
'xstatic.pkg.opensans', |
83 | 83 |
'xstatic.pkg.roboto_fontface', |
tests/test_cron.py | ||
---|---|---|
11 | 11 | |
12 | 12 |
@override_settings(STATISTICS_PROVIDERS=[]) |
13 | 13 |
def test_cron_run(app): |
14 |
with mock.patch('combo.apps.lingo.AppConfig.hourly') as hourly_job: |
|
14 |
with mock.patch('combo.apps.lingo.apps.AppConfig.hourly') as hourly_job:
|
|
15 | 15 |
call_command('cron') |
16 | 16 |
assert hourly_job.call_count == 1 |
17 | 17 | |
... | ... | |
23 | 23 | |
24 | 24 | |
25 | 25 |
def test_cron_error(app): |
26 |
with mock.patch('combo.apps.lingo.AppConfig.hourly') as hourly_job: |
|
26 |
with mock.patch('combo.apps.lingo.apps.AppConfig.hourly') as hourly_job:
|
|
27 | 27 |
hourly_job.side_effect = Exception('test error') |
28 | 28 |
out = StringIO() |
29 | 29 |
with pytest.raises(CommandError): |
30 |
- |