-
Notifications
You must be signed in to change notification settings - Fork 9
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
Formulario para la gestión de las secciones de la tabla de contenidos de los NÚMEROS de las revistas #727
Open
eduranm
wants to merge
7
commits into
scieloorg:main
Choose a base branch
from
eduranm:tk_628
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Formulario para la gestión de las secciones de la tabla de contenidos de los NÚMEROS de las revistas #727
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
07e13ff
Agrega app Toc en configuración
eduranm 1c59761
Agrega Modelo, Admin y archivo migrations para app Toc
eduranm 2df57bf
Agrega modelo IssueTOC
eduranm 668792e
Agrega area administrativa para IssueTOC
eduranm 2700b89
Archivo migrations
eduranm fd5b4e7
Agrega idioma en Journal Section
eduranm 0756bfa
Archivo migrations
eduranm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class TocConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "toc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,301 @@ | ||
# Generated by Django 5.0.3 on 2024-04-06 16:50 | ||
|
||
import django.db.models.deletion | ||
import modelcluster.fields | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
("core", "0003_gender_created_gender_creator_gender_updated_and_more"), | ||
("journal", "0022_alter_journal_vocabulary"), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="JournalSectionCode", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"sort_order", | ||
models.IntegerField(blank=True, editable=False, null=True), | ||
), | ||
( | ||
"created", | ||
models.DateTimeField( | ||
auto_now_add=True, verbose_name="Creation date" | ||
), | ||
), | ||
( | ||
"updated", | ||
models.DateTimeField( | ||
auto_now=True, verbose_name="Last update date" | ||
), | ||
), | ||
("code", models.TextField(blank=True, null=True, verbose_name="Code")), | ||
( | ||
"creator", | ||
models.ForeignKey( | ||
editable=False, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="%(class)s_creator", | ||
to=settings.AUTH_USER_MODEL, | ||
verbose_name="Creator", | ||
), | ||
), | ||
( | ||
"updated_by", | ||
models.ForeignKey( | ||
blank=True, | ||
editable=False, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="%(class)s_last_mod_user", | ||
to=settings.AUTH_USER_MODEL, | ||
verbose_name="Updater", | ||
), | ||
), | ||
], | ||
options={ | ||
"ordering": ["sort_order"], | ||
"abstract": False, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name="JournalSectionTitle", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"sort_order", | ||
models.IntegerField(blank=True, editable=False, null=True), | ||
), | ||
( | ||
"created", | ||
models.DateTimeField( | ||
auto_now_add=True, verbose_name="Creation date" | ||
), | ||
), | ||
( | ||
"updated", | ||
models.DateTimeField( | ||
auto_now=True, verbose_name="Last update date" | ||
), | ||
), | ||
("text", models.TextField(blank=True, null=True, verbose_name="Texto")), | ||
( | ||
"creator", | ||
models.ForeignKey( | ||
editable=False, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="%(class)s_creator", | ||
to=settings.AUTH_USER_MODEL, | ||
verbose_name="Creator", | ||
), | ||
), | ||
( | ||
"journal_section_title", | ||
modelcluster.fields.ParentalKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="journal_section_title", | ||
to="toc.journalsectioncode", | ||
), | ||
), | ||
( | ||
"language", | ||
models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
to="core.language", | ||
verbose_name="Idioma", | ||
), | ||
), | ||
( | ||
"updated_by", | ||
models.ForeignKey( | ||
blank=True, | ||
editable=False, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="%(class)s_last_mod_user", | ||
to=settings.AUTH_USER_MODEL, | ||
verbose_name="Updater", | ||
), | ||
), | ||
], | ||
options={ | ||
"ordering": ["sort_order"], | ||
"abstract": False, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name="JournalTOC", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"created", | ||
models.DateTimeField( | ||
auto_now_add=True, verbose_name="Creation date" | ||
), | ||
), | ||
( | ||
"updated", | ||
models.DateTimeField( | ||
auto_now=True, verbose_name="Last update date" | ||
), | ||
), | ||
( | ||
"creator", | ||
models.ForeignKey( | ||
editable=False, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="%(class)s_creator", | ||
to=settings.AUTH_USER_MODEL, | ||
verbose_name="Creator", | ||
), | ||
), | ||
( | ||
"journal", | ||
models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="+", | ||
to="journal.journal", | ||
verbose_name="Journal", | ||
), | ||
), | ||
( | ||
"updated_by", | ||
models.ForeignKey( | ||
blank=True, | ||
editable=False, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="%(class)s_last_mod_user", | ||
to=settings.AUTH_USER_MODEL, | ||
verbose_name="Updater", | ||
), | ||
), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
), | ||
migrations.AddField( | ||
model_name="journalsectioncode", | ||
name="journal_section_code", | ||
field=modelcluster.fields.ParentalKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="journal_section_code", | ||
to="toc.journaltoc", | ||
), | ||
), | ||
migrations.CreateModel( | ||
name="JournalSection", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"sort_order", | ||
models.IntegerField(blank=True, editable=False, null=True), | ||
), | ||
( | ||
"created", | ||
models.DateTimeField( | ||
auto_now_add=True, verbose_name="Creation date" | ||
), | ||
), | ||
( | ||
"updated", | ||
models.DateTimeField( | ||
auto_now=True, verbose_name="Last update date" | ||
), | ||
), | ||
( | ||
"section", | ||
models.TextField(blank=True, null=True, verbose_name="Section"), | ||
), | ||
( | ||
"creator", | ||
models.ForeignKey( | ||
editable=False, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="%(class)s_creator", | ||
to=settings.AUTH_USER_MODEL, | ||
verbose_name="Creator", | ||
), | ||
), | ||
( | ||
"updated_by", | ||
models.ForeignKey( | ||
blank=True, | ||
editable=False, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="%(class)s_last_mod_user", | ||
to=settings.AUTH_USER_MODEL, | ||
verbose_name="Updater", | ||
), | ||
), | ||
( | ||
"journal_section", | ||
modelcluster.fields.ParentalKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="journal_section", | ||
to="toc.journaltoc", | ||
), | ||
), | ||
], | ||
options={ | ||
"ordering": ["sort_order"], | ||
"abstract": False, | ||
}, | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
from django.db import models | ||
from django.utils.translation import gettext_lazy as _ | ||
from modelcluster.fields import ParentalKey | ||
from modelcluster.models import ClusterableModel | ||
from core.models import ( | ||
CommonControlField, | ||
TextWithLang, | ||
) | ||
from wagtail.models import Orderable | ||
from wagtail.admin.panels import InlinePanel, FieldPanel | ||
from wagtailautocomplete.edit_handlers import AutocompletePanel | ||
from journal.models import Journal | ||
|
||
|
||
class JournalTOC(CommonControlField, ClusterableModel): | ||
journal = models.ForeignKey( | ||
Journal, | ||
verbose_name=_("Journal"), | ||
on_delete=models.SET_NULL, | ||
related_name="+", | ||
null=True, | ||
blank=True, | ||
) | ||
|
||
panels = [ | ||
AutocompletePanel("journal"), | ||
InlinePanel("journal_section_code", label=_("Journal Section Code"), classname="collapsed"), | ||
InlinePanel("journal_section", label=_("Journal Section"), classname="collapsed"), | ||
] | ||
|
||
|
||
class JournalSectionCode(Orderable, CommonControlField, ClusterableModel): | ||
journal_section_code = ParentalKey( | ||
JournalTOC, | ||
null=True, | ||
blank=True, | ||
on_delete=models.SET_NULL, | ||
related_name="journal_section_code", | ||
) | ||
|
||
code = models.TextField(_("Code"), null=True, blank=True) | ||
|
||
panels = [ | ||
FieldPanel("code"), | ||
InlinePanel("journal_section_title", label=_("Journal Section Title"), classname="collapsed"), | ||
] | ||
|
||
autocomplete_search_field = "code" | ||
|
||
def autocomplete_label(self): | ||
return f"{self.code}" | ||
|
||
|
||
class JournalSectionTitle(Orderable, TextWithLang, CommonControlField): | ||
journal_section_title = ParentalKey( | ||
JournalSectionCode, | ||
null=True, | ||
blank=True, | ||
on_delete=models.SET_NULL, | ||
related_name="journal_section_title", | ||
) | ||
|
||
|
||
class JournalSection(Orderable, CommonControlField): | ||
journal_section = ParentalKey( | ||
JournalTOC, | ||
null=True, | ||
blank=True, | ||
on_delete=models.SET_NULL, | ||
related_name="journal_section", | ||
) | ||
|
||
section = models.TextField(_("Section"), null=True, blank=True) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.shortcuts import render | ||
|
||
# Create your views here. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eduranm creo que es importante indica la lengua de la sección. Pienso que una forma de solucionar el problema que le había yo comentado es añadir um ForeignKey / Autocomplete para self (la propia clase)