Skip to content

Commit

Permalink
Corrige importações de módulos do wagtail que ficarão obsoletos (#298)
Browse files Browse the repository at this point in the history
* Aplica black

* Remove espaços no início e no fim no XML ao obter XMLWithPre

* Troca wagtail.admin.edit_handlers por wagtail.admin.panels

* Troca DocumentChooserPanel por FieldPanel

* Corrige importação de wagtail core e hooks
  • Loading branch information
robertatakenaka authored Jul 30, 2023
1 parent 0f0fa62 commit 56de002
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 33 deletions.
4 changes: 2 additions & 2 deletions article/utils/parse_name_author.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import re
import re


def parse_author_name(name):
Expand All @@ -9,4 +9,4 @@ def parse_author_name(name):
if match:
return {"given_names": match.group(2), "surname": match.group(1)}
else:
return {"declared_name": name}
return {"declared_name": name}
2 changes: 1 addition & 1 deletion book/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.utils.translation import gettext as _
from modelcluster.fields import ParentalKey
from modelcluster.models import ClusterableModel
from wagtail.admin.edit_handlers import (
from wagtail.admin.panels import (
FieldPanel,
InlinePanel,
ObjectList,
Expand Down
4 changes: 2 additions & 2 deletions book/utils/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import re
import re


def parse_author_name(name):
Expand All @@ -9,4 +9,4 @@ def parse_author_name(name):
if match:
return {"given_names": match.group(2), "surname": match.group(1)}
else:
return {"declared_name": name}
return {"declared_name": name}
2 changes: 1 addition & 1 deletion doi/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.db import models
from django.utils.translation import gettext_lazy as _
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.admin.panels import FieldPanel

from core.choices import LANGUAGE
from core.forms import CoreAdminModelForm
Expand Down
14 changes: 3 additions & 11 deletions pid_provider/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ class PidProviderXMLAdmin(ModelAdmin):
"aop_pid",
"main_doi",
)
list_filter = (
"article_pub_year",
)
list_filter = ("article_pub_year",)
search_fields = (
"journal__title",
"pkg_name",
Expand Down Expand Up @@ -100,9 +98,7 @@ class PidChangeAdmin(ModelAdmin):
"new",
"pid_type",
)
list_filter = (
"pid_type",
)
list_filter = ("pid_type",)
search_fields = (
"old",
"new",
Expand All @@ -113,11 +109,7 @@ class PidProviderAdminGroup(ModelAdminGroup):
menu_label = _("Pid Provider")
menu_icon = "folder-open-inverse" # change as required
menu_order = 100 # will put in 3rd place (000 being 1st, 100 2nd)
items = (
PidProviderXMLAdmin,
PidRequestAdmin,
PidChangeAdmin
)
items = (PidProviderXMLAdmin, PidRequestAdmin, PidChangeAdmin)


modeladmin_register(PidProviderAdminGroup)
11 changes: 4 additions & 7 deletions researcher/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
from django.utils.translation import gettext_lazy as _
from modelcluster.fields import ParentalKey
from modelcluster.models import ClusterableModel
from wagtail.admin.edit_handlers import FieldPanel, InlinePanel, MultiFieldPanel
from wagtail.core.models import Orderable
from wagtail.documents.edit_handlers import DocumentChooserPanel
from wagtail.admin.panels import FieldPanel, InlinePanel, MultiFieldPanel
from wagtail.models import Orderable
from wagtailautocomplete.edit_handlers import AutocompletePanel

from core.models import CommonControlField, Gender
Expand All @@ -23,9 +22,7 @@ class Researcher(ClusterableModel, CommonControlField):
given_names = models.CharField(
_("Given names"), max_length=128, blank=True, null=True
)
last_name = models.CharField(
_("Last name"), max_length=128, blank=True, null=True
)
last_name = models.CharField(_("Last name"), max_length=128, blank=True, null=True)
declared_name = models.CharField(
_("Declared Name"), max_length=255, blank=True, null=True
)
Expand Down Expand Up @@ -263,4 +260,4 @@ class EditorialBoardMemberFile(models.Model):
def filename(self):
return os.path.basename(self.attachment.name)

panels = [DocumentChooserPanel("attachment")]
panels = [FieldPanel("attachment")]
2 changes: 1 addition & 1 deletion researcher/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
modeladmin_register,
)
from wagtail.contrib.modeladmin.views import CreateView
from wagtail.core import hooks
from wagtail import hooks

from .button_helper import EditorialBoardMemberHelper
from .models import EditorialBoardMember, EditorialBoardMemberFile, Researcher
Expand Down
6 changes: 2 additions & 4 deletions xmlsps/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,9 @@ def __str__(self):
@classmethod
def get_or_create(cls, journal, volume, number, suppl, pub_year):
if journal is None:
raise XMLIssueGetOrCreateError(
f"XMLIssue.get_or_create requires journal")
raise XMLIssueGetOrCreateError(f"XMLIssue.get_or_create requires journal")
if pub_year is None:
raise XMLIssueGetOrCreateError(
f"XMLIssue.get_or_create requires pub_year")
raise XMLIssueGetOrCreateError(f"XMLIssue.get_or_create requires pub_year")
try:
return cls.objects.get(
journal=journal,
Expand Down
4 changes: 1 addition & 3 deletions xmlsps/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ class XMLSPSAdmin(ModelAdmin):
"is_published",
"pid_v3",
)
list_filter = (
"is_published",
)
list_filter = ("is_published",)
search_fields = (
"pid_v3",
"pid_v2",
Expand Down
3 changes: 2 additions & 1 deletion xmlsps/xml_sps_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,15 @@ def get_xml_with_pre_from_uri(uri, timeout=30):

def get_xml_with_pre(xml_content):
try:
xml_content = xml_content.strip()
# return etree.fromstring(xml_content)
pref, xml = split_processing_instruction_doctype_declaration_and_xml(
xml_content
)
return XMLWithPre(pref, etree.fromstring(xml))

except Exception as e:
if xml_content.strip():
if xml_content:
raise GetXmlWithPreError(
"Unable to get xml with pre %s: %s ... %s"
% (e, xml_content[:100], xml_content[-200:])
Expand Down

0 comments on commit 56de002

Please sign in to comment.