Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mantém o main_ingress atualizado com conteúdo de main #427

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d8901eb
Corrige Institution.__str__, adiciona atributos de autocomplete e alt…
robertatakenaka Mar 11, 2024
9e82f25
Faz correções na app journal: adiciona Journal.title, wagtail_hooks.J…
robertatakenaka Mar 11, 2024
4c9e84d
Adiciona filtros de journal_acron e publication_year para migrar dado…
robertatakenaka Mar 14, 2024
97bd478
Garante que no XML migrado (seja nativo ou gerado a partir do HTML) t…
robertatakenaka Mar 15, 2024
d647f7b
Cria o procedimento de corrigir o valor do Pid v2 (#410)
robertatakenaka Mar 23, 2024
7a38778
Corrige ausencia de pid v3 no xml submetido do upload para o core (#411)
robertatakenaka Mar 24, 2024
a259b99
Atualiza dependencias base.txt e production.txt (#409)
samuelveigarangel Mar 24, 2024
ff068e8
Modifica comportamento de Pid provider, que passa a aceitar mudanças …
robertatakenaka Mar 27, 2024
1777455
Cria meio de configurar / habilitar / desabilitar fix_pid_v2 do Core …
robertatakenaka Mar 27, 2024
3b99916
Adiciona 'fixed_in_core': False ao retorno de fix_pid_v2 (#417)
robertatakenaka Mar 27, 2024
b7beffe
Evita que SPSPkg armazene arquivos em excesso (#418)
robertatakenaka Mar 27, 2024
911f87f
Verifica se xml registrado e xml recebido são iguais, somente após co…
robertatakenaka Mar 27, 2024
74e9767
Melhora ordem dos itens do menu (#408)
samuelveigarangel Mar 27, 2024
cb75b16
Move as operações anteriores de ArticleProc, IssueProc, JournalProc p…
robertatakenaka Mar 28, 2024
ebb61b5
Melhora o registro das operações das tarefas relacionadas à migração …
robertatakenaka Mar 29, 2024
e85d57a
Refatora upload parte 3 - agrupa em uma tarefa as validações: assets,…
robertatakenaka Mar 10, 2024
6e5a702
Refatora upload parte 3 - agrupa em uma tarefa as validações: assets,…
robertatakenaka Mar 10, 2024
cebf173
Refatora upload parte 2 - Adiciona funções em upload.controller para …
robertatakenaka Mar 10, 2024
769db66
Atualiza main_ingress com main (#425)
robertatakenaka Mar 31, 2024
79ef29e
Modifica a entrada do pacote pelo upload e adiciona novas validações …
robertatakenaka Mar 31, 2024
07eb66c
Refatora upload parte 3 - agrupa em uma tarefa as validações: assets,…
robertatakenaka Mar 10, 2024
afd5cef
Refatora upload parte 3 - agrupa em uma tarefa as validações: assets,…
robertatakenaka Mar 10, 2024
29fa764
Refatora upload parte 2 - Adiciona funções em upload.controller para …
robertatakenaka Mar 10, 2024
614776b
Atualiza main_ingress com main (#425)
robertatakenaka Mar 31, 2024
4ed97ec
Modifica a entrada do pacote pelo upload e adiciona novas validações …
robertatakenaka Mar 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions article/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,25 @@ class Meta:

base_form_class = ArticleForm

autocomplete_search_field = "pid_v3"
autocomplete_search_field = "sps_pkg__sps_pkg_name"

def autocomplete_label(self):
return self.pid_v3
return self.sps_pkg.sps_pkg_name

def __str__(self):
return f"{self.pid_v3}"
return f"{self.sps_pkg.sps_pkg_name}"

@property
def data(self):
# TODO completar com itens que identifique o artigo
return dict(
xml=self.sps_pkg and self.sps_pkg.xml_uri,
issue=self.issue.data,
journal=self.journal.data,
pid_v3=self.pid_v3,
created=created.isoformat(),
updated=updated.isoformat(),
)

@classmethod
def get(cls, pid_v3):
Expand Down
2 changes: 1 addition & 1 deletion article/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class ArticleModelAdmin(ModelAdmin):
inspect_view_enabled = True
inspect_view_class = ArticleAdminInspectView
menu_icon = "doc-full"
menu_order = 200
menu_order = get_menu_order("article")
add_to_settings_menu = False
exclude_from_explorer = False

Expand Down
4 changes: 4 additions & 0 deletions bigbang/tasks_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ def _schedule_migrate_document_files_and_records(username, enabled):
name="task_migrate_document_files",
kwargs=dict(
username=username,
journal_acron=None,
publication_year=None,
force_update=False,
),
description=_("Migra arquivos dos documentos"),
Expand All @@ -266,6 +268,8 @@ def _schedule_migrate_document_files_and_records(username, enabled):
name="task_migrate_document_records",
kwargs=dict(
username=username,
journal_acron=None,
publication_year=None,
force_update=False,
),
description=_("Migra registros dos documentos"),
Expand Down
4 changes: 2 additions & 2 deletions collection/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ class ClassicWebsiteConfigurationModelAdmin(ModelAdmin):
class CollectionModelAdminGroup(ModelAdminGroup):
menu_label = _("Collections")
menu_icon = "folder-open-inverse"
# menu_order = get_menu_order("collection")
menu_order = 100
menu_order = get_menu_order("collection")
# menu_order = 100
items = (
CollectionModelAdmin,
WebSiteConfigurationModelAdmin,
Expand Down
35 changes: 24 additions & 11 deletions config/menu.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
WAGTAIL_MENU_APPS_ORDER = {
"collection": 400,
"journal": 500,
"issue": 510,
"article": 520,
"upload": 700,
"migration": 710,
"location": 800,
"institution": 810,
}

WAGTAIL_MENU_APPS_ORDER = [
"Tarefas",
"unexpected-error",
"processing",
"migration",
"journal",
"issue",
"article",
"institution",
"location",
"researcher",
"collection",
"pid_provider",
"Configurações",
"Relatórios",
"Images",
"Documentos",
"Ajuda",
]

def get_menu_order(app_name):
return WAGTAIL_MENU_APPS_ORDER.get(app_name) or 100
try:
return WAGTAIL_MENU_APPS_ORDER.index(app_name) + 1
except:
return 9000

2 changes: 1 addition & 1 deletion config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"allauth.account",
"allauth.socialaccount",
"django_celery_beat",
"captcha",
# "captcha",
"wagtailcaptcha",
"wagtailmenus",
"rest_framework",
Expand Down
15 changes: 14 additions & 1 deletion core/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from collection.models import Collection
from article.models import Article
from wagtail.admin.navigation import get_site_for_user

from config.menu import get_menu_order, WAGTAIL_MENU_APPS_ORDER

# @hooks.register("insert_global_admin_css", order=100)
# def global_admin_css():
Expand Down Expand Up @@ -77,3 +77,16 @@ def add_items_summary_items(request, items):
items.append(CollectionSummaryItem(request))
items.append(JournalSummaryItem(request))
items.append(ArticleSummaryItem(request))


@hooks.register('construct_main_menu')
def reorder_menu_items(request, menu_items):
for item in menu_items:
if item.label in WAGTAIL_MENU_APPS_ORDER:
item.order = get_menu_order(item.label)


@hooks.register('construct_main_menu')
def remove_menu_items(request, menu_items):
if not request.user.is_superuser:
menu_items[:] = [item for item in menu_items if item.name not in ['documents', 'explorer', 'reports']]
16 changes: 16 additions & 0 deletions htmlxml/migrations/0002_alter_htmlxml_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 5.0.3 on 2024-03-29 17:32

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("htmlxml", "0001_initial"),
]

operations = [
migrations.AlterModelOptions(
name="htmlxml",
options={"ordering": ["-updated"]},
),
]
48 changes: 38 additions & 10 deletions htmlxml/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from core.models import CommonControlField
from package.models import BasicXMLFile
from migration.models import MigratedArticle

# from tracker.models import EventLogger
from tracker import choices as tracker_choices

Expand Down Expand Up @@ -84,6 +85,7 @@ class BodyAndBackFile(BasicXMLFile, Orderable):
]

class Meta:

indexes = [
models.Index(fields=["version"]),
]
Expand Down Expand Up @@ -133,9 +135,9 @@ def create_or_update(cls, user, bb_parent, version, file_content, pkg_name):
return obj
except Exception as e:
raise exceptions.CreateOrUpdateBodyAndBackFileError(
_(
"Unable to create_or_update_body and back file {} {} {} {}"
).format(bb_parent, version, type(e), e)
_("Unable to create_or_update_body and back file {} {} {} {}").format(
bb_parent, version, type(e), e
)
)


Expand Down Expand Up @@ -214,6 +216,7 @@ def data(self):
]

class Meta:

indexes = [
models.Index(fields=["attention_demands"]),
]
Expand Down Expand Up @@ -491,6 +494,8 @@ def autocomplete_label(self):
return self.migrated_article

class Meta:
ordering = ['-updated']

indexes = [
models.Index(fields=["html2xml_status"]),
models.Index(fields=["quality"]),
Expand Down Expand Up @@ -561,14 +566,25 @@ def html_to_xml(
):
try:
self.html2xml_status = tracker_choices.PROGRESS_STATUS_DOING
self.html_translation_langs = "-".join(sorted(article_proc.translations.keys()))
self.pdf_langs = "-".join(sorted([item.lang or article_proc.main_lang for item in article_proc.renditions]))
self.html_translation_langs = "-".join(
sorted(article_proc.translations.keys())
)
self.pdf_langs = "-".join(
sorted(
[
item.lang or article_proc.main_lang
for item in article_proc.renditions
]
)
)
self.save()

document = Document(article_proc.migrated_data.data)
document._translated_html_by_lang = article_proc.translations

body_and_back = self._generate_xml_body_and_back(user, article_proc, document)
body_and_back = self._generate_xml_body_and_back(
user, article_proc, document
)
xml_content = self._generate_xml_from_html(user, article_proc, document)

if xml_content and body_and_back:
Expand Down Expand Up @@ -615,7 +631,14 @@ def generate_report(self, user, article_proc):
else:
self.quality = choices.HTML2XML_QA_NOT_EVALUATED
self.save()
op.finish(user, completed=True)
op.finish(
user,
completed=True,
detail={
"attention_demands": self.attention_demands,
"quality": self.quality,
},
)
except Exception as e:
op.finish(user, completed=False, detail={"error": str(e)})

Expand All @@ -625,9 +648,12 @@ def _generate_xml_body_and_back(self, user, article_proc, document):
"""
done = False
operation = article_proc.start(user, "generate xml body and back")

languages = document._translated_html_by_lang
detail = {}
detail.update(languages)
try:
document.generate_body_and_back_from_html(document._translated_html_by_lang)
document.generate_body_and_back_from_html(languages)
done = True
except GenerateBodyAndBackFromHTMLError as e:
# cria xml_body_and_back padrão
Expand All @@ -645,7 +671,7 @@ def _generate_xml_body_and_back(self, user, article_proc, document):
file_content=xml_body_and_back,
pkg_name=article_proc.pkg_name,
)

detail["xml_to_html_steps"] = i
operation.finish(user, done, detail=detail)
return done

Expand All @@ -655,7 +681,9 @@ def _generate_xml_from_html(self, user, article_proc, document):
detail = {}
try:
xml_content = document.generate_full_xml(None).decode("utf-8")
self.save_file(article_proc.pkg_name + ".xml", xml_content)
xml_file = article_proc.pkg_name + ".xml"
self.save_file(xml_file, xml_content)
detail["xml"] = xml_file
except Exception as e:
detail = {"error": str(e)}
operation.finish(user, bool(xml_content), detail=detail)
Expand Down
12 changes: 9 additions & 3 deletions institution/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.utils.translation import gettext as _
from modelcluster.models import ClusterableModel
from wagtail.admin.panels import FieldPanel, InlinePanel
from wagtailautocomplete.edit_handlers import AutocompletePanel

from core.models import CommonControlField
from location.models import Location
Expand Down Expand Up @@ -48,8 +49,13 @@ class Institution(CommonControlField, ClusterableModel):
FieldPanel("logo"),
]

autocomplete_search_field = "name"

def autocomplete_label(self):
return str(self)

def __unicode__(self):
return "%s | %s | %s | %s | %s" % (
return "%s | %s | %s | %s | %s | %s" % (
self.name,
self.acronym,
self.level_1,
Expand All @@ -59,7 +65,7 @@ def __unicode__(self):
)

def __str__(self):
return "%s | %s | %s | %s | %s" % (
return "%s | %s | %s | %s | %s | %s" % (
self.name,
self.acronym,
self.level_1,
Expand Down Expand Up @@ -133,7 +139,7 @@ class InstitutionHistory(models.Model):
final_date = models.DateField(_("Final Date"), null=True, blank=True)

panels = [
FieldPanel("institution", heading=_("Institution")),
AutocompletePanel("institution", heading=_("Institution")),
FieldPanel("initial_date"),
FieldPanel("final_date"),
]
19 changes: 18 additions & 1 deletion issue/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ def __str__(self):
supplement = models.CharField(_("Supplement"), max_length=16, null=True, blank=True)
publication_year = models.CharField(_("Year"), max_length=4, null=True, blank=True)

@property
def data(self):
return dict(
journal=self.journal.data,
volume=self.volume,
number=self.number,
supplement=self.supplement,
publication_year=self.publication_year,
created=created.isoformat(),
updated=updated.isoformat(),
)

@staticmethod
def autocomplete_custom_queryset_filter(search_term):
parts = search_term.split()
Expand All @@ -60,7 +72,12 @@ def autocomplete_custom_queryset_filter(search_term):
)

def autocomplete_label(self):
return f"{self.journal.title} {self.volume or self.number}"
return "%s %s%s%s" % (
self.journal,
self.volume and f"v{self.volume}",
self.number and f"n{self.number}",
self.supplement and f"s{self.supplement}",
)

panels = [
AutocompletePanel("journal"),
Expand Down
4 changes: 1 addition & 3 deletions issue/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ class IssueAdmin(ModelAdmin):
menu_label = _("Issues")
create_view_class = IssueCreateView
menu_icon = "folder"
# menu_order = get_menu_order("issue")
menu_order = 300
menu_order = get_menu_order("issue")
add_to_settings_menu = False
exclude_from_explorer = False

Expand Down Expand Up @@ -63,7 +62,6 @@ class IssueModelAdminGroup(ModelAdminGroup):
IssueAdmin,
# IssueProcAdmin,
)
menu_order = get_menu_order("journal")


# modeladmin_register(IssueModelAdminGroup)
Expand Down
Loading