-
Notifications
You must be signed in to change notification settings - Fork 0
IMS Indicator on new version should update links to figures 282960 #50
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
Open
dobri1408
wants to merge
49
commits into
develop
Choose a base branch
from
update_datafigure
base: develop
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
Changes from 40 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
6df26b6
Update version.py
dobri1408 669f7db
Update version.py
dobri1408 1463702
Update version.py
dobri1408 d8f7eab
Update version.py
dobri1408 019ec1d
Update version.py
dobri1408 a6c72b6
Update version.py
dobri1408 9b54a98
Update version.py
dobri1408 432e22e
Update version.py
dobri1408 95ce986
Update version.py
dobri1408 42490ec
Update version.py
dobri1408 7e1fbb5
Update version.py
dobri1408 1bf5558
Update version.py
dobri1408 ad4fb61
Update version.py
dobri1408 f825391
Update version.py
dobri1408 7c7a00e
Update version.py
dobri1408 4692bf0
Update version.py
dobri1408 0e74225
Update version.py
dobri1408 0722087
Update version.py
dobri1408 36a72ed
Update version.py
dobri1408 3462bb3
Update version.py
dobri1408 5b2cda2
Update version.py
dobri1408 a51f7fb
Merge branch 'develop' into update_datafigure
dobri1408 b4ceb32
Update version.py
dobri1408 2965e73
Update version.py
dobri1408 7592d59
Update version.py
dobri1408 9c15011
chore: fix pep8
avoinea 0e77fa2
simplify
dobri1408 b5194c1
simplify
dobri1408 6ada665
clean spaces
dobri1408 5c36461
clean spaces
dobri1408 d574b88
fix pep8
dobri1408 5520424
please fix pep8
dobri1408 6d9c59a
please fix pep8
dobri1408 982e3e3
Add initial page to relatedItems
Narcis2005 93ddf36
Fix shortname changes breaking drafts
Narcis2005 b88b408
linting
Narcis2005 288f8b2
linting
Narcis2005 de97316
lLinting
Narcis2005 fc3fd1b
Linter
Narcis2005 6d0bb37
Merge pull request #54 from eea/fix_renaming
dobri1408 160b093
Stop using relatedItems and create new field, fix creating multiple d…
Narcis2005 06d69ed
Linter
Narcis2005 285f359
linting
Narcis2005 53cbd1f
Make field a simple uid
Narcis2005 cd645be
Linting
Narcis2005 06302fc
Linter
Narcis2005 561009c
Linter
Narcis2005 a46626e
Check if attribute exists
Narcis2005 5f687a5
Merge pull request #55 from eea/parent_draft
dobri1408 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
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
@@ -1,15 +1,21 @@ | ||
"""Copy action for content rules.""" | ||
|
||
from urllib.parse import urlparse | ||
from Acquisition import aq_base | ||
from OFS.event import ObjectClonedEvent | ||
from OFS.SimpleItem import SimpleItem | ||
import OFS.subscribers | ||
from plone.restapi.blocks import visit_blocks | ||
from plone.app.contentrules import PloneMessageFactory as _ | ||
from plone.app.contentrules.actions import ActionAddForm | ||
from plone.app.contentrules.actions import ActionEditForm | ||
from plone.app.contentrules.browser.formhelper import ContentRuleFormWrapper | ||
from plone.app.vocabularies.catalog import CatalogSource | ||
from plone.contentrules.rule.interfaces import IExecutable | ||
from plone.contentrules.rule.interfaces import IRuleElementData | ||
from plone.restapi.serializer.utils import uid_to_url | ||
from plone.restapi.deserializer.utils import path2uid | ||
|
||
try: | ||
from plone.base.utils import pretty_title_or_id | ||
except ImportError: | ||
|
@@ -19,11 +25,24 @@ | |
from Products.statusmessages.interfaces import IStatusMessage | ||
from ZODB.POSException import ConflictError | ||
from zope import schema | ||
from zope.component import adapter | ||
from zope.component import adapter, getUtility | ||
from zope.event import notify | ||
from zope.interface import implementer | ||
from zope.interface import Interface | ||
from zope.lifecycleevent import ObjectCopiedEvent | ||
from zope.interface import implementer, Interface | ||
from zope.lifecycleevent import ObjectCopiedEvent, modified | ||
from zope.intid.interfaces import IIntIds | ||
from z3c.relationfield.relation import RelationValue | ||
|
||
|
||
def getLink(path): | ||
""" | ||
Get link | ||
""" | ||
|
||
URL = urlparse(path) | ||
|
||
if URL.netloc.startswith("localhost") and URL.scheme: | ||
return path.replace(URL.scheme + "://" + URL.netloc, "") | ||
return path | ||
|
||
|
||
class ICopyAction(Interface): | ||
|
@@ -75,11 +94,13 @@ def __init__(self, context, element, event): | |
self.event = event | ||
|
||
def __call__(self): | ||
|
||
portal_url = getToolByName(self.context, "portal_url", None) | ||
if portal_url is None: | ||
return False | ||
|
||
obj = self.event.object | ||
previous_obj_path = obj.absolute_url_path() | ||
|
||
path = self.element.target_folder | ||
change_note = self.element.change_note | ||
|
@@ -100,7 +121,7 @@ def __call__(self): | |
|
||
old_id = obj.getId() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verify here if there is in related items an uid even if this is return .1, maybe that .1 is renamed |
||
new_id = self.generate_id(target, old_id) | ||
if not new_id.endswith('.1'): | ||
if not new_id.endswith(".1"): | ||
# Version already exists, redirect to it - refs #279130 | ||
return True | ||
|
||
|
@@ -123,14 +144,33 @@ def __call__(self): | |
obj.wl_clearLocks() | ||
|
||
obj._postCopy(target, op=0) | ||
try: | ||
intids = getUtility(IIntIds) | ||
relation = RelationValue(intids.getId(orig_obj)) | ||
obj.relatedItems = [relation] | ||
obj.reindexObject(idxs=["relatedItems"]) | ||
except Exception as e: | ||
self.error(obj, str(e)) | ||
|
||
OFS.subscribers.compatibilityCall("manage_afterClone", obj, obj) | ||
|
||
notify(ObjectClonedEvent(obj)) | ||
|
||
pr = getToolByName(obj, 'portal_repository') | ||
pr = getToolByName(obj, "portal_repository") | ||
pr.save(obj=obj, comment=change_note) | ||
|
||
# CHANGE URL OF FIGURES TO THE NEW DRAFT VERSION | ||
for block_data in visit_blocks(obj, obj.blocks): | ||
if (block_data.get("@type") == "embed_content" and | ||
"url" in block_data): | ||
url = uid_to_url(block_data["url"]) | ||
if previous_obj_path in url: | ||
url = url.replace( | ||
previous_obj_path, | ||
previous_obj_path + ".1" | ||
) | ||
url = path2uid(context=self.context, link=getLink(url)) | ||
block_data["url"] = url | ||
modified(obj) | ||
dobri1408 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return True | ||
|
||
def error(self, obj, error): | ||
|
@@ -169,6 +209,7 @@ class CopyAddForm(ActionAddForm): | |
|
||
class CopyAddFormView(ContentRuleFormWrapper): | ||
"""A wrapper for the add form.""" | ||
|
||
form = CopyAddForm | ||
|
||
|
||
|
@@ -186,4 +227,5 @@ class CopyEditForm(ActionEditForm): | |
|
||
class CopyEditFormView(ContentRuleFormWrapper): | ||
"""A wrapper for the edit form.""" | ||
|
||
form = CopyEditForm |
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.
Verify if relatedItems are here!
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.
Verify if relatedItems is also an Indicator