FUCK LINTERS TEST

This commit is contained in:
Yohann D'ANELLO 2020-02-10 21:12:12 +01:00
parent 343ab02874
commit 2753f700a6
1 changed files with 7 additions and 5 deletions

View File

@ -4,8 +4,8 @@
import json
import re
import urllib.request
import unicodedata
import urllib.request
from django.forms import ModelForm
@ -103,16 +103,18 @@ class MediaAdminForm(ModelForm):
self.download_data_openlibrary(isbn)
if self.cleaned_data['title']:
self.cleaned_data['title'] = re.sub('\(AUT\) ',
'', self.cleaned_data['title'])
self.cleaned_data['title'] = re.sub(r'\(AUT\) ',
'', self.cleaned_data['title'])
if self.cleaned_data['authors']:
authors = self.cleaned_data['authors']
old_authors = authors.copy()
def sort(author):
return str(-author.note) + "." \
+ str(old_authors.index(author)) \
+ "." + author.name
authors.sort(key=sort)
author_name = self.cleaned_data['authors'][0].name
if ',' not in author_name and ' ' in author_name:
@ -130,9 +132,9 @@ class MediaAdminForm(ModelForm):
if self.cleaned_data['subtitle']:
self.cleaned_data['subtitle'] = re.sub(r'</span>',
'', self.cleaned_data['subtitle'])
'', self.cleaned_data['subtitle'])
self.cleaned_data['subtitle'] = re.sub(r'<span.*>',
'', self.cleaned_data['subtitle'])
'', self.cleaned_data['subtitle'])
start = self.cleaned_data['subtitle'].split(' ')[0] \
.replace('.', '')