misc: apply pyupgrade (#55868)
This commit is contained in:
parent
8514d0d00e
commit
f4615c5061
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.12 on 2018-06-12 11:42
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ def asset_url(*args, **kwargs):
|
|||
asset = asset_object
|
||||
break
|
||||
|
||||
if isinstance(asset_object, six.string_types):
|
||||
if isinstance(asset_object, str):
|
||||
try:
|
||||
asset = Asset.objects.get(key=asset_object).asset
|
||||
break
|
||||
|
|
|
@ -39,7 +39,7 @@ from .forms import AssetsImportForm, AssetUploadForm
|
|||
from .models import Asset
|
||||
|
||||
|
||||
class CkEditorAsset(object):
|
||||
class CkEditorAsset:
|
||||
def __init__(self, filepath):
|
||||
self.filepath = filepath
|
||||
self.name = os.path.basename(filepath)
|
||||
|
@ -69,7 +69,7 @@ class CkEditorAsset(object):
|
|||
return ckeditor.views.is_image(self.src)
|
||||
|
||||
|
||||
class SlotAsset(object):
|
||||
class SlotAsset:
|
||||
def __init__(self, key=None, name=None, asset_type='image', asset=None):
|
||||
self.key = key
|
||||
self.name = name
|
||||
|
@ -98,7 +98,7 @@ class SlotAsset(object):
|
|||
|
||||
@classmethod
|
||||
def get_assets(cls):
|
||||
assets = dict([(x.key, x) for x in Asset.objects.all()])
|
||||
assets = {x.key: x for x in Asset.objects.all()}
|
||||
uniq_slots = {}
|
||||
uniq_slots.update(settings.COMBO_ASSET_SLOTS)
|
||||
cells = CellBase.get_cells(select_related={'__all__': ['page'], 'data_linkcell': ['link_page']})
|
||||
|
@ -131,7 +131,7 @@ class Assets(ListView):
|
|||
return files
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(Assets, self).get_context_data(**kwargs)
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['query'] = self.request.GET.get('q') or ''
|
||||
return context
|
||||
|
||||
|
@ -170,7 +170,7 @@ class AssetUpload(FormView):
|
|||
ckeditor_upload_view = ckeditor.views.ImageUploadView()
|
||||
self.request.GET = {'CKEditorFuncNum': '-'} # hack
|
||||
ckeditor_upload_view.post(self.request)
|
||||
return super(AssetUpload, self).form_valid(form)
|
||||
return super().form_valid(form)
|
||||
|
||||
def get_success_url(self):
|
||||
return Assets(request=self.request).get_anchored_url(name=self.request.FILES['upload'].name)
|
||||
|
@ -204,7 +204,7 @@ class AssetOverwrite(FormView):
|
|||
self.request,
|
||||
_('You have to upload a file with the same extension (%(ext)s).') % {'ext': ext_orig},
|
||||
)
|
||||
return super(AssetOverwrite, self).form_valid(form)
|
||||
return super().form_valid(form)
|
||||
|
||||
default_storage.delete(img_orig)
|
||||
if getattr(settings, 'CKEDITOR_IMAGE_BACKEND', None):
|
||||
|
@ -220,7 +220,7 @@ class AssetOverwrite(FormView):
|
|||
else:
|
||||
if backend.should_create_thumbnail(saved_path):
|
||||
backend.create_thumbnail(saved_path)
|
||||
return super(AssetOverwrite, self).form_valid(form)
|
||||
return super().form_valid(form)
|
||||
|
||||
def get_success_url(self):
|
||||
img_orig = self.request.GET['img']
|
||||
|
@ -254,7 +254,7 @@ class SlotAssets(ListView):
|
|||
|
||||
def get_assets(self, cell):
|
||||
asset_slots = cell.get_asset_slots()
|
||||
assets = dict([(x.key, x) for x in Asset.objects.filter(key__in=asset_slots.keys())])
|
||||
assets = {x.key: x for x in Asset.objects.filter(key__in=asset_slots.keys())}
|
||||
for key, value in asset_slots.items():
|
||||
yield SlotAsset(
|
||||
key,
|
||||
|
@ -293,7 +293,7 @@ class SlotAssetUpload(FormView):
|
|||
self.asset = Asset(key=self.kwargs['key'])
|
||||
self.asset.asset = self.request.FILES['upload']
|
||||
self.asset.save()
|
||||
return super(SlotAssetUpload, self).form_valid(form)
|
||||
return super().form_valid(form)
|
||||
|
||||
def get_success_url(self):
|
||||
if self.request.GET.get('cell_reference'):
|
||||
|
@ -349,9 +349,9 @@ class AssetsImport(FormView):
|
|||
import_assets(form.cleaned_data['assets_file'], overwrite)
|
||||
except tarfile.TarError:
|
||||
messages.error(self.request, _('The assets file is not valid.'))
|
||||
return super(AssetsImport, self).form_valid(form)
|
||||
return super().form_valid(form)
|
||||
messages.success(self.request, _('The assets file has been imported.'))
|
||||
return super(AssetsImport, self).form_valid(form)
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
assets_import = AssetsImport.as_view()
|
||||
|
@ -392,7 +392,7 @@ class AssetsExportSize(TemplateView):
|
|||
template_name = 'combo/manager_assets_export_size.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(AssetsExportSize, self).get_context_data(**kwargs)
|
||||
context = super().get_context_data(**kwargs)
|
||||
media_prefix = default_storage.path('')
|
||||
computed_size = 0
|
||||
for basedir, dirnames, filenames in os.walk(media_prefix):
|
||||
|
|
|
@ -37,7 +37,7 @@ class BookingCalendarForm(forms.ModelForm):
|
|||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(BookingCalendarForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
agenda_references = get_agendas()
|
||||
formdef_references = get_wcs_options('/api/formdefs/')
|
||||
self.fields['agenda_reference'].widget = forms.Select(choices=agenda_references)
|
||||
|
@ -47,7 +47,7 @@ class BookingCalendarForm(forms.ModelForm):
|
|||
class BookingForm(forms.Form):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.cell = kwargs.pop('cell')
|
||||
super(BookingForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.cleaned_data = {}
|
||||
|
||||
def is_valid(self):
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
|
||||
from django.db import migrations, models
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -59,16 +59,12 @@ class BookingCalendar(CellBase):
|
|||
return settings.BOOKING_CALENDAR_CELL_ENABLED and is_chrono_enabled() and is_wcs_enabled()
|
||||
|
||||
def is_visible(self, **kwargs):
|
||||
return (
|
||||
self.agenda_reference
|
||||
and self.formdef_reference
|
||||
and super(BookingCalendar, self).is_visible(**kwargs)
|
||||
)
|
||||
return self.agenda_reference and self.formdef_reference and super().is_visible(**kwargs)
|
||||
|
||||
def get_cell_extra_context(self, context):
|
||||
if context.get('placeholder_search_mode'):
|
||||
return {}
|
||||
extra_context = super(BookingCalendar, self).get_cell_extra_context(context)
|
||||
extra_context = super().get_cell_extra_context(context)
|
||||
events_data = get_chrono_events(self.agenda_reference, not (context.get('synchronous')))
|
||||
extra_context.update(
|
||||
get_calendar_context_vars(context['request'], extra_context['cell'], events_data)
|
||||
|
|
|
@ -128,7 +128,7 @@ def get_form_url_with_params(cell, data):
|
|||
return url
|
||||
|
||||
|
||||
class DaySlot(object):
|
||||
class DaySlot:
|
||||
def __init__(self, date_time, available, exist=True):
|
||||
self.date_time = localtime(make_aware(date_time))
|
||||
self.available = available
|
||||
|
@ -142,7 +142,7 @@ class DaySlot(object):
|
|||
return '%s' % self.date_time.isoformat()
|
||||
|
||||
|
||||
class WeekDay(object):
|
||||
class WeekDay:
|
||||
def __init__(self, date):
|
||||
self.date = date
|
||||
self.slots = []
|
||||
|
@ -168,7 +168,7 @@ class WeekDay(object):
|
|||
return max(self.slots, key=lambda x: x.date_time.time())
|
||||
|
||||
|
||||
class Calendar(object):
|
||||
class Calendar:
|
||||
def __init__(self, offset, days_displayed, min_duration):
|
||||
self.offset = offset
|
||||
self.days_displayed = days_displayed
|
||||
|
@ -227,7 +227,7 @@ class Calendar(object):
|
|||
return day.get_slot(slot.time())
|
||||
|
||||
def get_minimum_slot(self):
|
||||
return min([day.get_minimum_slot().date_time.time() for day in self.days])
|
||||
return min(day.get_minimum_slot().date_time.time() for day in self.days)
|
||||
|
||||
def get_maximum_slot(self):
|
||||
return max([day.get_maximum_slot().date_time.time() for day in self.days])
|
||||
return max(day.get_maximum_slot().date_time.time() for day in self.days)
|
||||
|
|
|
@ -49,7 +49,7 @@ class CalendarContentAjaxView(DetailView):
|
|||
template_name = 'calendar/booking_calendar_content.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(CalendarContentAjaxView, self).get_context_data(**kwargs)
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['cell'] = self.object
|
||||
events_data = get_chrono_events(self.object.agenda_reference, context.get('synchronous'))
|
||||
context.update(get_calendar_context_vars(self.request, self.object, events_data))
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ class DashboardCell(CellBase):
|
|||
for x in ValidityInfo.objects.filter(invalid_since__lt=now() - datetime.timedelta(days=2))
|
||||
}
|
||||
context['tiles'] = [x for x in tiles if (x.cell_type_id, x.cell_pk) not in validity_info_dict]
|
||||
return super(DashboardCell, self).render(context)
|
||||
return super().render(context)
|
||||
|
||||
|
||||
class Tile(models.Model):
|
||||
|
|
|
@ -158,7 +158,7 @@ def dashboard_auto_tile(request, *args, **kwargs):
|
|||
def dashboard_reorder_tiles(request, *args, **kwargs):
|
||||
dashboard = DashboardCell.objects.filter(page__snapshot__isnull=True)[0]
|
||||
new_order = request.GET['order'].split(',')
|
||||
tiles = dict((str(x.id), x) for x in Tile.objects.filter(id__in=new_order))
|
||||
tiles = {str(x.id): x for x in Tile.objects.filter(id__in=new_order)}
|
||||
for i, tile_id in enumerate(new_order):
|
||||
tile = tiles.get(tile_id)
|
||||
if tile.user != request.user:
|
||||
|
|
|
@ -34,7 +34,7 @@ class ChartForm(forms.ModelForm):
|
|||
fields = ('title', 'url')
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ChartForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
available_charts = []
|
||||
for site_key, site_dict in settings.KNOWN_SERVICES.get('bijoe').items():
|
||||
result = requests.get(
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
|
||||
from django.db import migrations, models
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.12 on 2019-03-28 07:57
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.12 on 2019-06-17 10:14
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.12 on 2019-03-28 10:11
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.contrib.postgres.fields import JSONField
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.18 on 2020-08-13 09:00
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.29 on 2020-11-26 14:57
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
@ -35,7 +33,7 @@ class Migration(migrations.Migration):
|
|||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='statistic',
|
||||
unique_together=set([('slug', 'site_slug', 'service_slug')]),
|
||||
unique_together={('slug', 'site_slug', 'service_slug')},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='chartngcell',
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.29 on 2020-11-30 14:26
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.29 on 2020-11-30 14:34
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.29 on 2020-12-02 13:24
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib.postgres.fields import JSONField
|
||||
from django.db import migrations
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.29 on 2020-12-15 15:24
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ class ChartCell(CellBase):
|
|||
return ''
|
||||
|
||||
def get_cell_extra_context(self, context):
|
||||
context = super(ChartCell, self).get_cell_extra_context(context)
|
||||
context = super().get_cell_extra_context(context)
|
||||
context['title'] = self.title
|
||||
context['url'] = self.url
|
||||
return context
|
||||
|
@ -271,7 +271,7 @@ class ChartNgCell(CellBase):
|
|||
)
|
||||
|
||||
def get_cell_extra_context(self, context):
|
||||
ctx = super(ChartNgCell, self).get_cell_extra_context(context)
|
||||
ctx = super().get_cell_extra_context(context)
|
||||
if self.chart_type == 'table' and self.statistic and self.statistic.url:
|
||||
try:
|
||||
chart = self.get_chart(raise_if_not_cached=not (context.get('synchronous')))
|
||||
|
@ -508,7 +508,7 @@ class ChartNgCell(CellBase):
|
|||
tmp_items = sorted(zip(chart.x_labels, data), key=lambda x: (x[1] or 0))
|
||||
elif self.sort_order == 'desc':
|
||||
tmp_items = sorted(zip(chart.x_labels, data), key=lambda x: (x[1] or 0), reverse=True)
|
||||
x_labels, sorted_data = zip(*[(label, value) for label, value in tmp_items])
|
||||
x_labels, sorted_data = zip(*((label, value) for label, value in tmp_items))
|
||||
chart.x_labels = list(x_labels)
|
||||
return list(sorted_data)
|
||||
|
||||
|
@ -568,12 +568,12 @@ class ChartNgCell(CellBase):
|
|||
|
||||
return format_duration
|
||||
elif measure == 'percent':
|
||||
percent_formatter = lambda x: '{:.1f}%'.format(x)
|
||||
percent_formatter = lambda x: f'{x:.1f}%'
|
||||
return percent_formatter
|
||||
|
||||
def make_percent(self, series_data):
|
||||
for i, values in enumerate(zip(*series_data)):
|
||||
sum_values = sum([v for v in values if v is not None])
|
||||
sum_values = sum(v for v in values if v is not None)
|
||||
if sum_values == 0:
|
||||
continue
|
||||
|
||||
|
@ -595,7 +595,7 @@ class ChartNgCell(CellBase):
|
|||
# "W" and "o" are interpreted by Django's date filter and should be left as is. First W is
|
||||
# backslash escaped to prevent it from being interpreted, translators should refer to Django's
|
||||
# documentation in order to know if the new letter resulting of translation should be escaped or not.
|
||||
'_week': gettext('\WW-o'),
|
||||
'_week': gettext(r'\WW-o'),
|
||||
'_month': 'm-Y',
|
||||
'_year': 'Y',
|
||||
'_weekday': 'l',
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import ckeditor.fields
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
|
||||
from django.db import migrations, models
|
||||
|
|
|
@ -52,7 +52,7 @@ class FamilyLinkView(FormView):
|
|||
messages.error(self.request, error_message)
|
||||
else:
|
||||
messages.info(self.request, _('Your account was successfully linked.'))
|
||||
return super(FamilyLinkView, self).form_valid(form)
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
class FamilyUnlinkView(TemplateView):
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
|
||||
from django.db import migrations, models
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ class RecentDocumentsCell(CellBase):
|
|||
user = kwargs.get('user')
|
||||
if not user or user.is_anonymous:
|
||||
return False
|
||||
return super(RecentDocumentsCell, self).is_visible(**kwargs)
|
||||
return super().is_visible(**kwargs)
|
||||
|
||||
@classmethod
|
||||
def is_enabled(cls):
|
||||
|
@ -105,7 +105,7 @@ class RecentDocumentsCell(CellBase):
|
|||
|
||||
def render(self, context):
|
||||
context.update(self.get_json('api/documents/recently-added/', context))
|
||||
return super(RecentDocumentsCell, self).render(context)
|
||||
return super().render(context)
|
||||
|
||||
|
||||
def get_fargo_services():
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -40,10 +40,10 @@ class ImageAddView(CreateView):
|
|||
form.instance.gallery_id = self.kwargs.get('gallery_pk')
|
||||
other_images = form.instance.gallery.image_set.all()
|
||||
if other_images:
|
||||
form.instance.order = max([x.order for x in other_images]) + 1
|
||||
form.instance.order = max(x.order for x in other_images) + 1
|
||||
else:
|
||||
form.instance.order = 0
|
||||
return super(ImageAddView, self).form_valid(form)
|
||||
return super().form_valid(form)
|
||||
|
||||
def get_success_url(self):
|
||||
return (
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.18 on 2020-01-31 15:40
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.17 on 2020-02-03 10:37
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class LatestPageUpdatesCell(CellBase):
|
|||
verbose_name = _('Latest Page Updates')
|
||||
|
||||
def get_cell_extra_context(self, context):
|
||||
extra_context = super(LatestPageUpdatesCell, self).get_cell_extra_context(context)
|
||||
extra_context = super().get_cell_extra_context(context)
|
||||
if self.root_page:
|
||||
pages = self.root_page.get_descendants_and_me()
|
||||
else:
|
||||
|
|
|
@ -98,7 +98,7 @@ class RegieForm(forms.ModelForm):
|
|||
]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(RegieForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
fields, initial = create_form_fields(
|
||||
self.instance.eopayment.get_parameters(scope='transaction'),
|
||||
self.instance.transaction_options,
|
||||
|
@ -107,7 +107,7 @@ class RegieForm(forms.ModelForm):
|
|||
self.initial.update(initial)
|
||||
|
||||
def save(self):
|
||||
instance = super(RegieForm, self).save()
|
||||
instance = super().save()
|
||||
instance.transaction_options = compute_json_field(
|
||||
self.instance.eopayment.get_parameters(scope='transaction'), self.cleaned_data
|
||||
)
|
||||
|
@ -121,7 +121,7 @@ class PaymentBackendForm(forms.ModelForm):
|
|||
fields = ['label', 'slug', 'service']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(PaymentBackendForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
fields, initial = create_form_fields(
|
||||
self.instance.eopayment.get_parameters(scope='global'), self.instance.service_options
|
||||
)
|
||||
|
@ -131,7 +131,7 @@ class PaymentBackendForm(forms.ModelForm):
|
|||
self.fields['service'].disabled = True
|
||||
|
||||
def save(self):
|
||||
instance = super(PaymentBackendForm, self).save()
|
||||
instance = super().save()
|
||||
instance.service_options = compute_json_field(
|
||||
self.instance.eopayment.get_parameters(scope='global'), self.cleaned_data
|
||||
)
|
||||
|
@ -148,7 +148,7 @@ class TransactionExportForm(forms.Form):
|
|||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(TransactionExportForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
today = datetime.date.today()
|
||||
self.initial['start_date'] = today - datetime.timedelta(days=30)
|
||||
self.initial['end_date'] = today
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# lingo - basket and payment system
|
||||
# Copyright (C) 2018 Entr'ouvert
|
||||
|
|
|
@ -95,7 +95,7 @@ class TransactionListView(ListView):
|
|||
paginate_by = 10
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(TransactionListView, self).get_context_data(**kwargs)
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['query'] = self.request.GET.get('q') or ''
|
||||
return context
|
||||
|
||||
|
@ -126,7 +126,7 @@ class BasketItemErrorListView(ListView):
|
|||
paginate_by = 10
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(BasketItemErrorListView, self).get_context_data(**kwargs)
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['query'] = self.request.GET.get('q') or ''
|
||||
return context
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.postgres.fields import JSONField
|
||||
from django.db import migrations, models
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib.postgres.fields import JSONField
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import ckeditor.fields
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import ckeditor.fields
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib.postgres.fields import JSONField
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import ckeditor.fields
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
|
||||
from django.db import migrations, models
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
import combo.data.fields
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib.postgres.fields import JSONField
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.8 on 2018-01-31 14:24
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.15 on 2018-10-05 15:33
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.18 on 2019-04-26 09:59
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.contrib.postgres.fields import JSONField
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.18 on 2019-04-26 09:24
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.18 on 2019-04-26 10:02
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.18 on 2019-05-14 12:02
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib.postgres.fields import JSONField
|
||||
from django.db import migrations, models
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.18 on 2020-03-31 13:12
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.29 on 2020-04-03 20:19
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.18 on 2020-06-08 10:22
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.18 on 2020-10-01 11:53
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# lingo - basket and payment system
|
||||
# Copyright (C) 2015 Entr'ouvert
|
||||
|
@ -68,7 +67,7 @@ class PaymentException(Exception):
|
|||
|
||||
class UnsignedPaymentException(PaymentException):
|
||||
def __init__(self, transaction, *args, **kwargs):
|
||||
super(UnsignedPaymentException, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.transaction = transaction
|
||||
|
||||
|
||||
|
@ -163,7 +162,7 @@ class PaymentBackend(models.Model):
|
|||
|
||||
def make_eopayment(self, *, request=None, automatic_return_url=None, normal_return_url=None, **kwargs):
|
||||
options = self.service_options or {}
|
||||
if isinstance(options, six.string_types):
|
||||
if isinstance(options, str):
|
||||
# backward compatibility when used againt postgresql < 9.4 and
|
||||
# service_options is received as a string.
|
||||
try:
|
||||
|
@ -329,7 +328,7 @@ class Regie(models.Model):
|
|||
qs.update(is_default=False)
|
||||
elif not self.__class__.objects.filter(is_default=True).exists():
|
||||
self.is_default = True
|
||||
super(Regie, self).save(*args, **kwargs)
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
def natural_key(self):
|
||||
return (self.slug,)
|
||||
|
@ -688,7 +687,7 @@ class BasketItem(models.Model):
|
|||
return reverse('basket-item-pay-view', kwargs={'item_signature': signature})
|
||||
|
||||
|
||||
class RemoteItem(object):
|
||||
class RemoteItem:
|
||||
payment_date = None
|
||||
|
||||
def __init__(
|
||||
|
@ -745,7 +744,7 @@ class RemoteItem(object):
|
|||
|
||||
@classmethod
|
||||
def transactions_for_remote_items(cls, queryset, remote_items):
|
||||
remote_item_ids = set(remote_item.id for remote_item in remote_items if not remote_item.paid)
|
||||
remote_item_ids = {remote_item.id for remote_item in remote_items if not remote_item.paid}
|
||||
if not remote_item_ids:
|
||||
return Transaction.objects.none()
|
||||
|
||||
|
@ -878,7 +877,7 @@ class Transaction(models.Model):
|
|||
'unable to notify payment for remote item %s from transaction %s', item_id, self
|
||||
)
|
||||
else:
|
||||
logger.info(u'notified payment for remote item %s from transaction %s', item_id, self)
|
||||
logger.info('notified payment for remote item %s from transaction %s', item_id, self)
|
||||
subject = _('Invoice #%s') % remote_item.display_id
|
||||
local_item = BasketItem.objects.create(
|
||||
user=self.user,
|
||||
|
@ -1066,10 +1065,10 @@ class LingoBasketCell(CellBase):
|
|||
items = BasketItem.get_items_to_be_paid(context['request'].user)
|
||||
if not items:
|
||||
return
|
||||
total = sum([x.amount for x in items])
|
||||
total = sum(x.amount for x in items)
|
||||
if total == int(total):
|
||||
total = int(total)
|
||||
return {'badge': _(u'%s€') % localize(total)}
|
||||
return {'badge': _('%s€') % localize(total)}
|
||||
|
||||
def render(self, context):
|
||||
basket_template = template.loader.get_template('lingo/combo/basket.html')
|
||||
|
@ -1081,7 +1080,7 @@ class LingoBasketCell(CellBase):
|
|||
regies[item.regie_id]['items'].append(item)
|
||||
|
||||
for items in regies.values():
|
||||
items['total'] = sum([x.amount for x in items['items']])
|
||||
items['total'] = sum(x.amount for x in items['items'])
|
||||
|
||||
context['regies'] = sorted(regies.values(), key=lambda x: x['regie'].label)
|
||||
return basket_template.render(context)
|
||||
|
@ -1147,7 +1146,7 @@ class LingoBasketLinkCell(CellBase):
|
|||
return ''
|
||||
basket_template = template.loader.get_template('lingo/combo/basket_link.html')
|
||||
context['items'] = BasketItem.get_items_to_be_paid(user=context['request'].user)
|
||||
context['total'] = sum([x.amount for x in context['items']])
|
||||
context['total'] = sum(x.amount for x in context['items'])
|
||||
return basket_template.render(context)
|
||||
|
||||
|
||||
|
@ -1198,7 +1197,7 @@ class Items(CellBase):
|
|||
return [], []
|
||||
|
||||
def get_cell_extra_context(self, context):
|
||||
ctx = super(Items, self).get_cell_extra_context(context)
|
||||
ctx = super().get_cell_extra_context(context)
|
||||
if context.get('placeholder_search_mode'):
|
||||
# don't call webservices when we're just looking for placeholders
|
||||
return ctx
|
||||
|
@ -1220,7 +1219,7 @@ class Items(CellBase):
|
|||
self.context = context
|
||||
if not context.get('synchronous'):
|
||||
raise NothingInCacheException()
|
||||
return super(Items, self).render(context)
|
||||
return super().render(context)
|
||||
|
||||
|
||||
@register_cell_class
|
||||
|
@ -1273,7 +1272,7 @@ class SelfDeclaredInvoicePayment(Items):
|
|||
def render(self, context):
|
||||
context['synchronous'] = True
|
||||
context['page_path'] = context['request'].path
|
||||
return super(SelfDeclaredInvoicePayment, self).render(context)
|
||||
return super().render(context)
|
||||
|
||||
|
||||
TIPI_CONTROL_PROCOTOLS = (
|
||||
|
@ -1326,7 +1325,7 @@ class TipiPaymentFormCell(CellBase):
|
|||
return getattr(settings, 'LINGO_TIPI_CELL_PAYMENT_URL', 'https://www.payfip.gouv.fr/tpa/paiement.web')
|
||||
|
||||
def get_cell_extra_context(self, context):
|
||||
extra_context = super(TipiPaymentFormCell, self).get_cell_extra_context(context)
|
||||
extra_context = super().get_cell_extra_context(context)
|
||||
form_fields = self.get_default_form_class().base_fields
|
||||
field_definitions = (
|
||||
{'protocol': 'any', 'fields': ['exer']},
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# lingo - basket and payment system
|
||||
# Copyright (C) 2020 Entr'ouvert
|
||||
#
|
||||
|
|
|
@ -98,9 +98,9 @@ def lingo_check_request_signature(request):
|
|||
class LocaleDecimal(Decimal):
|
||||
# accept , instead of . for French users comfort
|
||||
def __new__(cls, value="0", *args, **kwargs):
|
||||
if isinstance(value, six.string_types) and settings.LANGUAGE_CODE.startswith('fr-'):
|
||||
if isinstance(value, str) and settings.LANGUAGE_CODE.startswith('fr-'):
|
||||
value = value.replace(',', '.')
|
||||
return super(LocaleDecimal, cls).__new__(cls, value, *args, **kwargs)
|
||||
return super().__new__(cls, value, *args, **kwargs)
|
||||
|
||||
|
||||
class RegiesApiView(ListView):
|
||||
|
@ -121,11 +121,11 @@ class AddBasketItemApiView(View):
|
|||
|
||||
@csrf_exempt
|
||||
def dispatch(self, *args, **kwargs):
|
||||
return super(AddBasketItemApiView, self).dispatch(*args, **kwargs)
|
||||
return super().dispatch(*args, **kwargs)
|
||||
|
||||
def get_amount(self, amount):
|
||||
if isinstance(amount, list):
|
||||
d = Decimal(sum([LocaleDecimal(a) for a in amount]))
|
||||
d = Decimal(sum(LocaleDecimal(a) for a in amount))
|
||||
else:
|
||||
d = LocaleDecimal(amount)
|
||||
return d.quantize(Decimal('0.01'), ROUND_HALF_UP)
|
||||
|
@ -237,7 +237,7 @@ class RemoveBasketItemApiView(View):
|
|||
|
||||
@csrf_exempt
|
||||
def dispatch(self, *args, **kwargs):
|
||||
return super(RemoveBasketItemApiView, self).dispatch(*args, **kwargs)
|
||||
return super().dispatch(*args, **kwargs)
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
if not lingo_check_request_signature(request):
|
||||
|
@ -285,7 +285,7 @@ class ValidateTransactionApiView(View):
|
|||
|
||||
@csrf_exempt
|
||||
def dispatch(self, *args, **kwargs):
|
||||
return super(ValidateTransactionApiView, self).dispatch(*args, **kwargs)
|
||||
return super().dispatch(*args, **kwargs)
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
if not lingo_check_request_signature(request):
|
||||
|
@ -295,22 +295,22 @@ class ValidateTransactionApiView(View):
|
|||
transaction = Transaction.objects.get(id=request.GET['transaction_id'])
|
||||
except Transaction.DoesNotExist:
|
||||
logger.warning(
|
||||
u'received validate request for unknown transaction %s', request.GET['transaction_id']
|
||||
'received validate request for unknown transaction %s', request.GET['transaction_id']
|
||||
)
|
||||
raise Http404
|
||||
|
||||
amount = LocaleDecimal(request.GET['amount'])
|
||||
|
||||
logger.info(u'validating amount %s for transaction %s', amount, smart_text(transaction.id))
|
||||
logger.info('validating amount %s for transaction %s', amount, smart_text(transaction.id))
|
||||
try:
|
||||
result = transaction.make_eopayment(request=request).backend.validate(
|
||||
amount, transaction.bank_data
|
||||
)
|
||||
except eopayment.ResponseError as e:
|
||||
logger.error(u'failed in validation operation: %s', e)
|
||||
logger.error('failed in validation operation: %s', e)
|
||||
return JsonResponse({'err': 1, 'e': force_text(e)})
|
||||
|
||||
logger.info(u'bank validation result: %r', result)
|
||||
logger.info('bank validation result: %r', result)
|
||||
operation = TransactionOperation(
|
||||
transaction=transaction, kind='validation', amount=amount, bank_result=result
|
||||
)
|
||||
|
@ -324,7 +324,7 @@ class CancelTransactionApiView(View):
|
|||
|
||||
@csrf_exempt
|
||||
def dispatch(self, *args, **kwargs):
|
||||
return super(CancelTransactionApiView, self).dispatch(*args, **kwargs)
|
||||
return super().dispatch(*args, **kwargs)
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
if not lingo_check_request_signature(request):
|
||||
|
@ -334,20 +334,20 @@ class CancelTransactionApiView(View):
|
|||
transaction = Transaction.objects.get(id=request.GET['transaction_id'])
|
||||
except Transaction.DoesNotExist:
|
||||
logger.warning(
|
||||
u'received validate request for unknown transaction %s', request.GET['transaction_id']
|
||||
'received validate request for unknown transaction %s', request.GET['transaction_id']
|
||||
)
|
||||
raise Http404
|
||||
|
||||
amount = LocaleDecimal(request.GET['amount'])
|
||||
|
||||
logger.info(u'cancelling amount %s for transaction %s', amount, smart_text(transaction.id))
|
||||
logger.info('cancelling amount %s for transaction %s', amount, smart_text(transaction.id))
|
||||
try:
|
||||
result = transaction.make_eopayment(request=request).backend.cancel(amount, transaction.bank_data)
|
||||
except eopayment.ResponseError as e:
|
||||
logger.error(u'failed in cancel operation: %s', e)
|
||||
logger.error('failed in cancel operation: %s', e)
|
||||
return JsonResponse({'err': 1, 'e': force_text(e)})
|
||||
|
||||
logger.info(u'bank cancellation result: %r', result)
|
||||
logger.info('bank cancellation result: %r', result)
|
||||
operation = TransactionOperation(
|
||||
transaction=transaction, kind='cancellation', amount=amount, bank_result=result
|
||||
)
|
||||
|
@ -356,7 +356,7 @@ class CancelTransactionApiView(View):
|
|||
return JsonResponse({'err': 0, 'extra': result})
|
||||
|
||||
|
||||
class PayMixin(object):
|
||||
class PayMixin:
|
||||
@atomic
|
||||
def handle_payment(
|
||||
self, request, regie, items, remote_items, next_url='/', email='', firstname='', lastname=''
|
||||
|
@ -381,17 +381,17 @@ class PayMixin(object):
|
|||
messages.error(request, _('Some items are already paid.'))
|
||||
return HttpResponseRedirect(next_url)
|
||||
|
||||
total_amount = sum([x.amount for x in remote_items or items])
|
||||
total_amount = sum(x.amount for x in remote_items or items)
|
||||
|
||||
if total_amount < regie.payment_min_amount:
|
||||
messages.warning(request, _(u'Minimal payment amount is %s €.') % regie.payment_min_amount)
|
||||
messages.warning(request, _('Minimal payment amount is %s €.') % regie.payment_min_amount)
|
||||
return HttpResponseRedirect(
|
||||
get_payment_status_view(next_url=next_url if remote_items else items[0].source_url)
|
||||
)
|
||||
|
||||
for item in items:
|
||||
if item.regie != regie:
|
||||
messages.error(request, _(u'Invalid grouping for basket items.'))
|
||||
messages.error(request, _('Invalid grouping for basket items.'))
|
||||
return HttpResponseRedirect(next_url)
|
||||
user = request.user if request.user.is_authenticated else None
|
||||
transaction = Transaction()
|
||||
|
@ -454,7 +454,7 @@ class PayMixin(object):
|
|||
messages.error(request, _('Failed to initiate payment request'))
|
||||
return HttpResponseRedirect(get_payment_status_view(next_url=next_url))
|
||||
logger.info(
|
||||
u'emitted payment request with id %s',
|
||||
'emitted payment request with id %s',
|
||||
smart_text(order_id),
|
||||
extra={'eopayment_order_id': smart_text(order_id), 'eopayment_data': repr(data)},
|
||||
)
|
||||
|
@ -505,14 +505,14 @@ class PayView(PayMixin, View):
|
|||
for item_id in request.POST.getlist('item'):
|
||||
remote_items.append(regie.get_invoice(user, item_id, update_paid=True))
|
||||
except (requests.exceptions.RequestException, RemoteInvoiceException):
|
||||
messages.error(request, _(u'Technical error: impossible to retrieve invoices.'))
|
||||
messages.error(request, _('Technical error: impossible to retrieve invoices.'))
|
||||
return HttpResponseRedirect(next_url)
|
||||
except ObjectDoesNotExist:
|
||||
messages.error(request, _(u'No invoice was found.'))
|
||||
messages.error(request, _('No invoice was found.'))
|
||||
return HttpResponseRedirect(next_url)
|
||||
else:
|
||||
if user is None:
|
||||
messages.error(request, _(u'Payment requires to be logged in.'))
|
||||
messages.error(request, _('Payment requires to be logged in.'))
|
||||
return HttpResponseRedirect(next_url)
|
||||
|
||||
if not regie_id:
|
||||
|
@ -521,7 +521,7 @@ class PayView(PayMixin, View):
|
|||
regie_id = items[0].regie_id
|
||||
for item in items:
|
||||
if item.regie_id != regie_id:
|
||||
messages.error(request, _(u'Invalid grouping for basket items.'))
|
||||
messages.error(request, _('Invalid grouping for basket items.'))
|
||||
return HttpResponseRedirect(next_url)
|
||||
|
||||
regie = Regie.objects.get(id=regie_id)
|
||||
|
@ -540,7 +540,7 @@ class PayView(PayMixin, View):
|
|||
capture_date = items[0].capture_date
|
||||
for item in items:
|
||||
if item.capture_date != capture_date:
|
||||
messages.error(request, _(u'Invalid grouping for basket items: different capture dates.'))
|
||||
messages.error(request, _('Invalid grouping for basket items: different capture dates.'))
|
||||
return HttpResponseRedirect(next_url)
|
||||
|
||||
if user:
|
||||
|
@ -549,7 +549,7 @@ class PayView(PayMixin, View):
|
|||
# user is not authenticated, it comes from ItemCell where an email
|
||||
# can be given in the payment form.
|
||||
if not request.POST.get('email'):
|
||||
messages.warning(request, _(u'You must give an email address.'))
|
||||
messages.warning(request, _('You must give an email address.'))
|
||||
return HttpResponseRedirect(request.POST.get('item_url'))
|
||||
email = request.POST.get('email')
|
||||
|
||||
|
@ -634,7 +634,7 @@ class PaymentView(View):
|
|||
raise Http404("A payment backend or regie primary key or slug must be specified")
|
||||
|
||||
payment = payment_backend.make_eopayment(request=request)
|
||||
logger.info(u'received payment response: %r', backend_response)
|
||||
logger.info('received payment response: %r', backend_response)
|
||||
try:
|
||||
eopayment_response_kwargs = {'redirect': not callback}
|
||||
if transaction is not None:
|
||||
|
@ -647,7 +647,7 @@ class PaymentView(View):
|
|||
payment_response = payment.response(backend_response, **eopayment_response_kwargs)
|
||||
except eopayment.PaymentException as e:
|
||||
logger.error(
|
||||
u'failed to process payment response: %s',
|
||||
'failed to process payment response: %s',
|
||||
e,
|
||||
extra={'eopayment_raw_response': repr(backend_response)},
|
||||
)
|
||||
|
@ -674,13 +674,13 @@ class CallbackView(PaymentView):
|
|||
|
||||
@csrf_exempt
|
||||
def dispatch(self, *args, **kwargs):
|
||||
return super(CallbackView, self).dispatch(*args, **kwargs)
|
||||
return super().dispatch(*args, **kwargs)
|
||||
|
||||
|
||||
class ReturnView(PaymentView):
|
||||
@csrf_exempt
|
||||
def dispatch(self, *args, **kwargs):
|
||||
return super(ReturnView, self).dispatch(*args, **kwargs)
|
||||
return super().dispatch(*args, **kwargs)
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
return self.handle_return(request, request.environ['QUERY_STRING'], **kwargs)
|
||||
|
@ -735,7 +735,7 @@ class ReturnView(PaymentView):
|
|||
|
||||
|
||||
class ItemDownloadView(View):
|
||||
http_method_names = [u'get']
|
||||
http_method_names = ['get']
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
try:
|
||||
|
@ -768,7 +768,7 @@ class ItemDownloadView(View):
|
|||
|
||||
|
||||
class ItemView(TemplateView):
|
||||
http_method_names = [u'get']
|
||||
http_method_names = ['get']
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
ret = {'item_url': self.request.get_full_path()}
|
||||
|
@ -804,7 +804,7 @@ class CancelItemView(DetailView):
|
|||
template_name = 'lingo/combo/cancel-item.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(CancelItemView, self).get_context_data(**kwargs)
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['basket_url'] = get_basket_url()
|
||||
return context
|
||||
|
||||
|
@ -831,7 +831,7 @@ class SelfInvoiceView(View):
|
|||
|
||||
@csrf_exempt
|
||||
def dispatch(self, *args, **kwargs):
|
||||
return super(SelfInvoiceView, self).dispatch(*args, **kwargs)
|
||||
return super().dispatch(*args, **kwargs)
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
try:
|
||||
|
@ -902,7 +902,7 @@ class PaymentStatusView(View):
|
|||
next_url = request.session.get('lingo_next_url', {}).get(str(transaction_id))
|
||||
if not next_url:
|
||||
next_url = get_basket_url()
|
||||
if len(set([item.source_url for item in transaction.items.all()])) == 1:
|
||||
if len({item.source_url for item in transaction.items.all()}) == 1:
|
||||
next_url = transaction.items.first().source_url
|
||||
next_url = request.build_absolute_uri(next_url)
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class MapLayerForm(forms.ModelForm):
|
|||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MapLayerForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
if self.instance.pk is None:
|
||||
# new instance, delete some fields
|
||||
del self.fields['slug']
|
||||
|
@ -71,7 +71,7 @@ class MapLayerForm(forms.ModelForm):
|
|||
del self.fields[field]
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super(MapLayerForm, self).clean()
|
||||
cleaned_data = super().clean()
|
||||
|
||||
if self.instance.kind == 'tiles' and cleaned_data.get('tiles_default') is True:
|
||||
if MapLayer.objects.filter(kind='tiles', tiles_default=True).exclude(pk=self.instance.pk):
|
||||
|
@ -88,7 +88,7 @@ class MapLayerOptionsForm(forms.ModelForm):
|
|||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.kind = kwargs.pop('kind')
|
||||
super(MapLayerOptionsForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
# if edition, no possibility to change the layer
|
||||
if self.instance.pk:
|
||||
del self.fields['map_layer']
|
||||
|
|
|
@ -26,7 +26,7 @@ from .forms import MapLayerForm, MapLayerOptionsForm
|
|||
from .models import Map, MapLayer, MapLayerOptions
|
||||
|
||||
|
||||
class MapLayerMixin(object):
|
||||
class MapLayerMixin:
|
||||
model = MapLayer
|
||||
success_url = reverse_lazy('maps-manager-homepage')
|
||||
|
||||
|
@ -36,7 +36,7 @@ class ManagerHomeView(MapLayerMixin, ListView):
|
|||
ordering = ['kind', 'label']
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ManagerHomeView, self).get_context_data(**kwargs)
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['map_list'] = Map.objects.all()
|
||||
return context
|
||||
|
||||
|
@ -46,7 +46,7 @@ class LayerAddView(MapLayerMixin, CreateView):
|
|||
template_name = 'maps/map_layer_form.html'
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super(LayerAddView, self).get_form_kwargs()
|
||||
kwargs = super().get_form_kwargs()
|
||||
kwargs['instance'] = self.model(kind=self.kwargs['kind'])
|
||||
return kwargs
|
||||
|
||||
|
@ -69,10 +69,10 @@ class MapCellAddLayer(CreateView):
|
|||
self.cell = CellBase.get_cell(kwargs['cell_reference'], page=kwargs['page_pk'])
|
||||
except Map.DoesNotExist:
|
||||
raise Http404
|
||||
return super(MapCellAddLayer, self).dispatch(request, *args, **kwargs)
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super(MapCellAddLayer, self).get_form_kwargs()
|
||||
kwargs = super().get_form_kwargs()
|
||||
kwargs['instance'] = MapLayerOptions(map_cell=self.cell)
|
||||
kwargs['kind'] = self.kwargs['kind']
|
||||
return kwargs
|
||||
|
@ -84,7 +84,7 @@ class MapCellAddLayer(CreateView):
|
|||
comment=_('added layer "%(layer)s" to cell "%(cell)s"')
|
||||
% {'layer': form.instance.map_layer, 'cell': self.cell},
|
||||
)
|
||||
return super(MapCellAddLayer, self).form_valid(form)
|
||||
return super().form_valid(form)
|
||||
|
||||
def get_success_url(self):
|
||||
return '%s#cell-%s' % (
|
||||
|
@ -106,13 +106,13 @@ class MapCellEditLayer(UpdateView):
|
|||
except Map.DoesNotExist:
|
||||
raise Http404
|
||||
self.object = get_object_or_404(MapLayerOptions, pk=kwargs['layeroptions_pk'], map_cell=self.cell)
|
||||
return super(MapCellEditLayer, self).dispatch(request, *args, **kwargs)
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_object(self, *args, **kwargs):
|
||||
return self.object
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super(MapCellEditLayer, self).get_form_kwargs()
|
||||
kwargs = super().get_form_kwargs()
|
||||
kwargs['kind'] = self.object.map_layer.kind
|
||||
return kwargs
|
||||
|
||||
|
@ -123,7 +123,7 @@ class MapCellEditLayer(UpdateView):
|
|||
comment=_('changed options of layer "%(layer)s" in cell "%(cell)s"')
|
||||
% {'layer': form.instance.map_layer, 'cell': self.cell},
|
||||
)
|
||||
return super(MapCellEditLayer, self).form_valid(form)
|
||||
return super().form_valid(form)
|
||||
|
||||
def get_success_url(self):
|
||||
return '%s#cell-%s' % (
|
||||
|
@ -144,13 +144,13 @@ class MapCellDeleteLayer(DeleteView):
|
|||
except Map.DoesNotExist:
|
||||
raise Http404
|
||||
self.object = get_object_or_404(MapLayerOptions, pk=kwargs['layeroptions_pk'], map_cell=self.cell)
|
||||
return super(MapCellDeleteLayer, self).dispatch(request, *args, **kwargs)
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_object(self, *args, **kwargs):
|
||||
return self.object
|
||||
|
||||
def delete(self, request, *args, **kwargs):
|
||||
response = super(MapCellDeleteLayer, self).delete(request, *args, **kwargs)
|
||||
response = super().delete(request, *args, **kwargs)
|
||||
PageSnapshot.take(
|
||||
self.cell.page,
|
||||
request=self.request,
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
from combo.apps.maps.models import ICONS
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue