Skip to content

Commit

Permalink
Merge pull request #899 from ZeitOnline/WCM-153
Browse files Browse the repository at this point in the history
WCM-153: make page writeable and add interred fields
  • Loading branch information
wosc authored Nov 6, 2024
2 parents 04dce42 + 84f06b6 commit 0e00144
Show file tree
Hide file tree
Showing 13 changed files with 210 additions and 164 deletions.
1 change: 1 addition & 0 deletions core/docs/changelog/WCM-153.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WCM-153: make page writeable and add interred fields
12 changes: 7 additions & 5 deletions core/src/zeit/cms/content/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class ICommonMetadata(zope.interface.Interface):

volume = zope.schema.Int(title=_('Volume'), min=1, max=54, required=False)

page = zope.schema.Int(title=_('Page'), readonly=True, required=False)
page = zope.schema.Int(title=_('Page'), required=False)

ressort = zope.schema.Choice(
title=_('Ressort'), source=zeit.cms.content.sources.RessortSource()
Expand Down Expand Up @@ -216,12 +216,14 @@ class ICommonMetadata(zope.interface.Interface):

advertisement_text = zope.schema.Text(title=_('Advertisement text'), required=False)

ir_mediasync_id = zope.schema.TextLine(
title=_('InterRed MediaSync ID'), required=False, readonly=True
ir_mediasync_id = zope.schema.Int(
title=_('InterRed MediaSync ID'),
required=False,
)

ir_article_id = zope.schema.TextLine(
title=_('InterRed Article ID'), required=False, readonly=True
ir_article_id = zope.schema.Int(
title=_('InterRed Article ID'),
required=False,
)


Expand Down
34 changes: 19 additions & 15 deletions core/src/zeit/content/article/edit/browser/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,25 @@ class CommentsFormGroup(zeit.edit.browser.form.FoldableFormGroup):
title = _('Comments')


class PrintFormGroup(zeit.edit.browser.form.FoldableFormGroup):
title = _('Print')


class PrintMetadata(zeit.edit.browser.form.InlineForm):
legend = _('')
prefix = 'print-metadata'
form_fields = FormFields(ICommonMetadata).select('year', 'volume', 'page', 'printRessort')

def _success_handler(self):
self.signal('reload-inline-view', 'edit.heading')


class PrintInterred(zeit.edit.browser.form.InlineForm):
legend = _('Interred')
prefix = 'print-interred'
form_fields = FormFields(ICommonMetadata).select('ir_article_id', 'ir_mediasync_id')


class Comments(zeit.edit.browser.form.InlineForm):
legend = _('')
prefix = 'metadata-comments'
Expand Down Expand Up @@ -381,21 +400,6 @@ class OptionsA(zeit.edit.browser.form.InlineForm):
form_fields = FormFields(IArticle).select('serie')


class OptionsB(zeit.edit.browser.form.InlineForm):
legend = ''
prefix = 'options-b'
form_fields = FormFields(ICommonMetadata).select('year', 'volume', 'page', 'printRessort')

def setUpWidgets(self, *args, **kw):
super().setUpWidgets(*args, **kw)
# the 'page' field is an Int, so we can't use default='n/a'
if not self.context.page:
self.widgets['page'].setRenderedValue('n/a')

def _success_handler(self):
self.signal('reload-inline-view', 'edit.heading')


class OptionsC(zeit.edit.browser.form.InlineForm):
legend = ''
prefix = 'options-c'
Expand Down
73 changes: 53 additions & 20 deletions core/src/zeit/content/article/edit/browser/form.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,59 @@
permission="zope.View"
/>

<!-- print -->

<browser:viewlet
for="zeit.content.article.interfaces.IArticle"
layer="zeit.cms.browser.interfaces.ICMSLayer"
view="zeit.edit.browser.form.Forms"
manager="zeit.edit.interfaces.IContentViewletManager"
name="print"
class=".form.PrintFormGroup"
permission="zope.View"
weight="15"
/>

<browser:viewlet
for="zeit.content.article.interfaces.IArticle"
layer="zeit.cms.browser.interfaces.ICMSLayer"
view=".form.PrintFormGroup"
manager="zeit.edit.interfaces.IContentViewletManager"
name="edit.form.print-metadata"
class="zeit.edit.browser.form.FormLoader"
permission="zope.View"
weight="20"
/>

<browser:page
for="zeit.content.article.interfaces.IArticle"
layer="zeit.cms.browser.interfaces.ICMSLayer"
name="edit.form.print-metadata"
class=".form.PrintMetadata"
permission="zope.View"
/>

<browser:viewlet
for="zeit.content.article.interfaces.IArticle"
layer="zeit.cms.browser.interfaces.ICMSLayer"
view=".form.PrintFormGroup"
manager="zeit.edit.interfaces.IContentViewletManager"
name="edit.form.print-interred"
class="zeit.edit.browser.form.FormLoader"
permission="zope.View"
weight="20"
/>

<browser:page
for="zeit.content.article.interfaces.IArticle"
layer="zeit.cms.browser.interfaces.ICMSLayer"
name="edit.form.print-interred"
class=".form.PrintInterred"
permission="zope.View"
/>

<!-- comments -->

<browser:viewlet
for="zeit.content.article.interfaces.IArticle"
layer="zeit.cms.browser.interfaces.ICMSLayer"
Expand Down Expand Up @@ -635,26 +688,6 @@
permission="zope.View"
/>

<browser:viewlet
for="zeit.content.article.interfaces.IArticle"
layer="zeit.cms.browser.interfaces.ICMSLayer"
view=".form.OptionFormGroup"
manager="zeit.edit.interfaces.IContentViewletManager"
name="edit.form.options-b"
class="zeit.edit.browser.form.FormLoader"
permission="zope.View"
weight="20"
/>

<browser:page
for="zeit.content.article.interfaces.IArticle"
layer="zeit.cms.browser.interfaces.ICMSLayer"
name="edit.form.options-b"
class=".form.OptionsB"
permission="zope.View"
/>


<browser:viewlet
for="zeit.content.article.interfaces.IArticle"
layer="zeit.cms.browser.interfaces.ICMSLayer"
Expand Down
26 changes: 16 additions & 10 deletions core/src/zeit/content/article/edit/browser/resources/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@
.type-article #edit-form-metadata > .block-inner,
.type-article #edit-form-misc > .block-inner,
.type-article #edit-form-article-content > .block-inner,
.type-article #edit-form-print > .block-inner,
.type-article #edit-form-recensions > .block-inner,
.type-article #edit-form-keywords-new > .block-inner,
.type-article #edit-form-workflow > .block-inner {
Expand Down Expand Up @@ -1288,24 +1289,25 @@
padding-top: 15px;
}

.type-article #edit-form-misc .fieldname-volume .display,
.type-article #edit-form-misc .fieldname-year .display {
width: 85px;
.type-article #edit-form-print #form-print-metadata {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}

.type-article #edit-form-misc .fieldname-page .display {
width: 30px;
.type-article #edit-form-print #form-print-metadata .fieldname-year input {
width: 40px;
}

.type-article #edit-form-misc .fieldname-printRessort .display {
width: 134px;
.type-article #edit-form-print #form-print-metadata .fieldname-volume input {
width: 40px;
}

.type-article #options-b\.year,
.type-article #options-b\.volume {
width: 85px;
.type-article #edit-form-print #form-print-metadata .fieldname-page input {
width: 40px;
}


.type-article #article-content-main-image\.main_image .object-details{
margin-bottom:10px;
}
Expand Down Expand Up @@ -1630,6 +1632,7 @@

.type-article #edit-form-filename .inline-form .fieldtype-text,
.type-article #edit-form-misc .inline-form .fieldtype-text,
.type-article #edit-form-print .inline-form .fieldtype-text,
.type-article #edit-form-metadata .inline-form .fieldtype-text {
float: left;
}
Expand All @@ -1646,6 +1649,7 @@

.type-article #edit-form-filename .inline-form .fieldtype-checkbox .widget,
.type-article #edit-form-misc .inline-form .fieldtype-checkbox .widget,
.type-article #edit-form-print .inline-form .fieldtype-checkbox .widget,
.type-article #edit-form-metadata .inline-form .fieldtype-checkbox .widget,
.type-article #edit-form-workflow .inline-form .fieldtype-checkbox .widget {
margin-left: 0.2em;
Expand All @@ -1663,12 +1667,14 @@

.type-article #edit-form-filename .inline-form .fieldtype-label,
.type-article #edit-form-misc .inline-form .fieldtype-label,
.type-article #edit-form-print .inline-form .fieldtype-label,
.type-article #edit-form-metadata .inline-form .fieldtype-label {
float: left;
}

.type-article #edit-form-filename .inline-form .fieldtype-label .widget,
.type-article #edit-form-misc .inline-form .fieldtype-label .widget,
.type-article #edit-form-print .inline-form .fieldtype-label .widget,
.type-article #edit-form-metadata .inline-form .fieldtype-label .widget {
margin-left: 0.2em;
margin-top: 0.2em;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,7 @@ def test_save_on_server_if_dirty(self):
def test_toolbar_actions_mark_editor_as_dirty(self):
self.create('<p>foo</p><p>bar</p>')
self.mark_dirty(status=False)
self.execute("document.getElementById('edit-form-article-content').scrollIntoView();")
click(self.selenium, 'link=H3')
self.assertEqual(True, self.eval(self.get_js_editable() + '.dirty'))

Expand Down
10 changes: 2 additions & 8 deletions core/src/zeit/content/article/edit/browser/tests/test_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,21 @@ def test_displays_last_published_information(self):


class PageNumberDisplay(zeit.content.article.testing.BrowserTestCase):
def test_no_page_displays_as_not_applicable(self):
b = self.browser
b.open('http://localhost/++skin++vivi/repository' '/online/2007/01/Somalia/@@checkout')
b.open('@@edit.form.options-b')
self.assertEllipsis('...Page...n/a...', b.contents)

def test_existing_page_number_is_displayed(self):
article = zeit.cms.interfaces.ICMSContent('http://xml.zeit.de/online/2007/01/Somalia')
with zeit.cms.checkout.helper.checked_out(article) as co:
co.page = '4711'
b = self.browser
b.open('http://localhost/++skin++vivi/repository' '/online/2007/01/Somalia/@@checkout')
b.open('@@edit.form.options-b')
b.open('@@edit.form.print-metadata')
self.assertEllipsis('...Page...4711...', b.contents)


class HeaderSync(zeit.content.article.edit.browser.testing.EditorTestCase):
def setUp(self):
super().setUp()
self.open('/repository/online/2007/01/Somalia/@@checkout')
self.selenium.waitForElementPresent('id=options-b.year')
self.selenium.waitForElementPresent('id=print-metadata.year')

def test_header_is_reloaded_after_change_to_ressort(self):
s = self.selenium
Expand Down
40 changes: 20 additions & 20 deletions core/src/zeit/content/article/edit/browser/tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@ def setUp(self):
super().setUp()
self.open('/repository/online/2007/01/Somalia/@@checkout')
s = self.selenium
s.waitForElementPresent('id=options-b.year')
s.click('css=#edit-form-misc .fold-link')
s.waitForElementPresent('id=print-metadata.year')
s.click('css=#edit-form-print .fold-link')

def test_form_should_highlight_changed_data(self):
s = self.selenium
s.assertValue('id=options-b.year', '2007')
s.assertValue('id=print-metadata.year', '2007')
s.assertElementNotPresent('css=.widget-outer.dirty')
s.type('id=options-b.year', '2010')
s.click('id=options-b.volume')
s.type('id=print-metadata.year', '2010')
s.click('id=print-metadata.volume')
s.waitForElementPresent('css=.field.dirty')

def test_form_should_save_entered_text_on_blur(self):
s = self.selenium
s.assertValue('id=options-b.year', '2007')
s._find('id=options-b.year').clear()
s.assertValue('id=print-metadata.year', '2007')
s._find('id=print-metadata.year').clear()
s.waitForElementNotPresent('css=.field.dirty')
s.type('id=options-b.year', '2010')
s.keyPress('id=options-b.volume', Keys.TAB)
s.type('id=options-b.printRessort', 'Politik')
s.keyPress('id=options-b.printRessort', Keys.TAB) # Trigger blur
s.type('id=print-metadata.year', '2010')
s.keyPress('id=print-metadata.volume', Keys.TAB)
s.type('id=print-metadata.printRessort', 'Politik')
s.keyPress('id=print-metadata.printRessort', Keys.TAB) # Trigger blur
s.waitForElementNotPresent('css=.field.dirty')
# Re-open the page and verify that the data is still there
s.clickAndWait('link=Edit contents')
s.waitForElementPresent('id=options-b.year')
s.assertValue('id=options-b.year', '2010')
s.waitForElementPresent('id=options-b.year')
s.assertValue('id=options-b.printRessort', 'Politik')
s.waitForElementPresent('id=print-metadata.year')
s.assertValue('id=print-metadata.year', '2010')
s.waitForElementPresent('id=print-metadata.year')
s.assertValue('id=print-metadata.printRessort', 'Politik')

def test_form_should_save_selection_on_blur(self):
s = self.selenium
Expand Down Expand Up @@ -77,10 +77,10 @@ def test_change_in_ressort_should_update_subressort_list(self):

def test_invalid_input_should_display_error_message(self):
s = self.selenium
s.assertValue('id=options-b.year', '2007')
s.type('id=options-b.year', 'ASDF')
s.keyPress('id=options-b.volume', Keys.TAB)
s.keyPress('id=options-b.printRessort', Keys.TAB) # Trigger blur
s.assertValue('id=print-metadata.year', '2007')
s.type('id=print-metadata.year', 'ASDF')
s.keyPress('id=print-metadata.volume', Keys.TAB)
s.keyPress('id=print-metadata.printRessort', Keys.TAB) # Trigger blur
s.waitForElementPresent('css=.inline-form div.error')

def test_relateds_should_be_addable(self):
Expand Down Expand Up @@ -132,7 +132,7 @@ class CommentsTest(zeit.content.article.edit.browser.testing.EditorTestCase):
def setUp(self):
super().setUp()
self.open('/repository/online/2007/01/Somalia/@@checkout')
self.selenium.waitForElementPresent('id=options-b.year')
self.selenium.waitForElementPresent('id=print-metadata.year')
self.selenium.click('css=#edit-form-comments .fold-link')

def test_comments_allowed_toggled_when_comments_section_is_toggled(self):
Expand Down
2 changes: 1 addition & 1 deletion core/src/zeit/content/volume/browser/tests/test_toc.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def test_create_toc_element_should_flatten_linebreaks(self):
'supertitle': '',
'access': 'frei verfügbar',
'authors': 'Helmut Schmidt',
'article_id': '0123456',
'article_id': '123456',
}
toc = Toc(mock.Mock(), mock.Mock())
result = toc._create_toc_element(article)
Expand Down
2 changes: 1 addition & 1 deletion core/src/zeit/content/volume/browser/toc.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def _get_metadata_from_article(self, article):
'supertitle': article.supertitle,
'access': article.access,
'authors': ', '.join([x.target.display_name for x in article.authorships]),
'article_id': article.ir_article_id,
'article_id': str(article.ir_article_id),
}
return self._normalize_toc_element(result)

Expand Down
Binary file modified core/src/zeit/locales/de/LC_MESSAGES/zeit.cms.mo
Binary file not shown.
Loading

0 comments on commit 0e00144

Please sign in to comment.