Skip to content

Commit

Permalink
[fc] Repository: plone.app.robotframework
Browse files Browse the repository at this point in the history
Branch: refs/heads/master
Date: 2017-03-14T15:17:12+01:00
Author: Stephan Geulette (sgeulette) <s.geulette@imio.be>
Commit: plone/plone.app.robotframework@9ecc1ca

Manage datetime and date field types in "set field value" keyword

Files changed:
M CHANGES.rst
M CONTRIBUTORS.rst
M src/plone/app/robotframework/content.py
Repository: plone.app.robotframework
Branch: refs/heads/master
Date: 2017-03-14T16:30:08+02:00
Author: Asko Soukka (datakurre) <asko.soukka@iki.fi>
Commit: plone/plone.app.robotframework@fdac6b1

Merge pull request #65 from IMIO/master

Manage datetime and date field types in "set field value" keyword

Files changed:
M CHANGES.rst
M CONTRIBUTORS.rst
M src/plone/app/robotframework/content.py
  • Loading branch information
datakurre committed Mar 14, 2017
1 parent 4221712 commit cdeda36
Showing 1 changed file with 105 additions and 161 deletions.
266 changes: 105 additions & 161 deletions last_commit.txt
Original file line number Diff line number Diff line change
@@ -1,206 +1,150 @@
Repository: plone.app.multilingual
Repository: plone.app.robotframework


Branch: refs/heads/master
Date: 2017-02-07T14:34:42+02:00
Author: Asko Soukka (datakurre) <asko.soukka@iki.fi>
Commit: https://github.com/plone/plone.app.multilingual/commit/838db18dae5f04e273c20f925e19d393acc54660
Date: 2017-03-14T15:17:12+01:00
Author: Stephan Geulette (sgeulette) <s.geulette@imio.be>
Commit: https://github.com/plone/plone.app.robotframework/commit/9ecc1ca425dea6871ba687c0b94e37aa53a23971

Add '@@tg' view for accessing translation group of the object TTW
Manage datetime and date field types in "set field value" keyword

Files changed:
M CHANGES.rst
M src/plone/app/multilingual/browser/configure.zcml
M src/plone/app/multilingual/browser/helper_views.py
M src/plone/app/multilingual/tests/test_api.py
M CONTRIBUTORS.rst
M src/plone/app/robotframework/content.py

diff --git a/CHANGES.rst b/CHANGES.rst
index 0fe6c2c..5092de1 100644
index 6af5242..7b7124b 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -10,7 +10,9 @@ Breaking changes:
@@ -10,7 +10,8 @@ king changes:

New features:

-- *add item here*
+- Add a new view ``@@tg`` for translatable content. It will return the
+ current translation group of the content, matching the bahavior of ``@@uuid``
+ of ``plone.app.uuid`` returning UUID of the content. [datakurre]
+- Manage datetime and date field types in "set field value" keyword
+ [sgeulette]

Bug fixes:

diff --git a/src/plone/app/multilingual/browser/configure.zcml b/src/plone/app/multilingual/browser/configure.zcml
index 6373c85..cbe747a 100644
--- a/src/plone/app/multilingual/browser/configure.zcml
+++ b/src/plone/app/multilingual/browser/configure.zcml
@@ -142,6 +142,14 @@
permission="zope.Public"
layer="..interfaces.IPloneAppMultilingualInstalled"/>
diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst
index f1a29c0..71b2897 100644
--- a/CONTRIBUTORS.rst
+++ b/CONTRIBUTORS.rst
@@ -22,6 +22,7 @@
- Roman Kozlovskyi
- Silvio Tomatis
- Steffen Lindner
+- Stephan Geulette
- Timo Stollenwerk
- Victor Fernandez de Alba
- zotya
diff --git a/src/plone/app/robotframework/content.py b/src/plone/app/robotframework/content.py
index c33e065..adde094 100644
--- a/src/plone/app/robotframework/content.py
+++ b/src/plone/app/robotframework/content.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+from datetime import datetime
import os

+ <!-- Translation Group -->
+ <browser:page
+ name="tg"
+ for="plone.app.multilingual.interfaces.ITranslatable"
+ class=".helper_views.TGView"
+ permission="zope.Public"
+ layer="..interfaces.IPloneAppMultilingualInstalled"/>
+
<!-- Selector -->
<browser:page
name="multilingual-selector"
diff --git a/src/plone/app/multilingual/browser/helper_views.py b/src/plone/app/multilingual/browser/helper_views.py
index a379c45..34cd0a2 100644
--- a/src/plone/app/multilingual/browser/helper_views.py
+++ b/src/plone/app/multilingual/browser/helper_views.py
@@ -9,6 +9,7 @@
from borg.localrole.interfaces import IFactoryTempFolder
from plone.app.layout.navigation.interfaces import INavigationRoot
from plone.app.multilingual.interfaces import IMultiLanguageExtraOptionsSchema
+from plone.app.multilingual.interfaces import ITG
from plone.app.multilingual.browser.selector import NOT_TRANSLATED_YET_TEMPLATE
from plone.app.multilingual.browser.selector import addQuery
from plone.app.multilingual.interfaces import ILanguageRootFolder
@@ -278,3 +279,11 @@ def language_name(self, lang=None):
if lang_info is None:
return None
return lang_info.get('native', None) or lang_info.get('name')
+
+
+class TGView(BrowserView):
+ """A simple browser view that renders the TG of its context
+ """
+
+ def __call__(self):
+ return str(ITG(self.context, u""))
diff --git a/src/plone/app/multilingual/tests/test_api.py b/src/plone/app/multilingual/tests/test_api.py
index 9776a65..e7d1ce0 100644
--- a/src/plone/app/multilingual/tests/test_api.py
+++ b/src/plone/app/multilingual/tests/test_api.py
@@ -3,6 +3,7 @@
from Products.CMFCore.utils import getToolByName
from plone.app.multilingual import api
from Products.CMFPlone.interfaces import ILanguage
+from plone.app.multilingual.interfaces import ATTRIBUTE_NAME
from plone.app.multilingual.interfaces import ITranslationIdChooser
from plone.app.multilingual.interfaces import ITranslationLocator
from plone.app.multilingual.interfaces import ITranslationManager
@@ -293,3 +294,13 @@ def test_locator(self):

child_locator = ITranslationLocator(subfolder_ca)
self.assertEqual(child_locator('es'), folder_es)
+
+ def test_tg_view(self):
+ a_ca = createContentInContainer(
+ self.portal['ca'],
+ 'Document',
+ title=u"Test document"
+ )
+ tg = getattr(a_ca, ATTRIBUTE_NAME)
+ self.assertTrue(bool(tg))
+ self.assertEqual(a_ca.restrictedTraverse('@@tg')(), tg)
@@ -173,6 +174,20 @@ def set_field_value(self, uid, field, value, field_type):
value = int(value)
if field_type == 'list':
value = eval(value)
+ if field_type.startswith('datetime'):
+ # field_type must begin with 'datetime'
+ # followed by optional format 'datetime%Y%m%d%H%M'
+ # without format: %Y%m%d%H%M is used
+ field_type = field_type[8:]
+ fmt = field_type and field_type or '%Y%m%d%H%M'
+ value = datetime.strptime(value, fmt)
+ if field_type.startswith('date'):
+ # field_type must begin with 'date'
+ # followed by optional format 'date%Y%m%d'
+ # without format: %Y%m%d is used
+ field_type = field_type[4:]
+ fmt = field_type and field_type or '%Y%m%d'
+ value = datetime.strptime(value, fmt).date()
if field_type == 'reference' and HAS_DEXTERITY_RELATIONS:
results_referenced = pc.unrestrictedSearchResults(UID=value)
referenced_obj = results_referenced[0]._unrestrictedGetObject()


Repository: plone.app.multilingual
Repository: plone.app.robotframework


Branch: refs/heads/master
Date: 2017-03-09T18:43:35+01:00
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at>
Commit: https://github.com/plone/plone.app.multilingual/commit/380aa0c4f0b78e29445fed75e2d1a85249b87944
Date: 2017-03-14T16:30:08+02:00
Author: Asko Soukka (datakurre) <asko.soukka@iki.fi>
Commit: https://github.com/plone/plone.app.robotframework/commit/fdac6b1b92948ee1108fdf1e39e22d1fd002bb50

Merge pull request #261 from plone/datakurre-tg-view
Merge pull request #65 from IMIO/master

Add '@@tg' view for accessing translation group of the object TTW
Manage datetime and date field types in "set field value" keyword

Files changed:
M CHANGES.rst
M src/plone/app/multilingual/browser/configure.zcml
M src/plone/app/multilingual/browser/helper_views.py
M src/plone/app/multilingual/tests/test_api.py
M CONTRIBUTORS.rst
M src/plone/app/robotframework/content.py

diff --git a/CHANGES.rst b/CHANGES.rst
index d4747d2..2e1734e 100644
index 6af5242..7b7124b 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -10,7 +10,9 @@ Breaking changes:
@@ -10,7 +10,8 @@ king changes:

New features:

-- *add item here*
+- Add a new view ``@@tg`` for translatable content. It will return the
+ current translation group of the content, matching the bahavior of ``@@uuid``
+ of ``plone.app.uuid`` returning UUID of the content. [datakurre]
+- Manage datetime and date field types in "set field value" keyword
+ [sgeulette]

Bug fixes:

diff --git a/src/plone/app/multilingual/browser/configure.zcml b/src/plone/app/multilingual/browser/configure.zcml
index 6373c85..cbe747a 100644
--- a/src/plone/app/multilingual/browser/configure.zcml
+++ b/src/plone/app/multilingual/browser/configure.zcml
@@ -142,6 +142,14 @@
permission="zope.Public"
layer="..interfaces.IPloneAppMultilingualInstalled"/>
diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst
index f1a29c0..71b2897 100644
--- a/CONTRIBUTORS.rst
+++ b/CONTRIBUTORS.rst
@@ -22,6 +22,7 @@
- Roman Kozlovskyi
- Silvio Tomatis
- Steffen Lindner
+- Stephan Geulette
- Timo Stollenwerk
- Victor Fernandez de Alba
- zotya
diff --git a/src/plone/app/robotframework/content.py b/src/plone/app/robotframework/content.py
index c33e065..adde094 100644
--- a/src/plone/app/robotframework/content.py
+++ b/src/plone/app/robotframework/content.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+from datetime import datetime
import os

+ <!-- Translation Group -->
+ <browser:page
+ name="tg"
+ for="plone.app.multilingual.interfaces.ITranslatable"
+ class=".helper_views.TGView"
+ permission="zope.Public"
+ layer="..interfaces.IPloneAppMultilingualInstalled"/>
+
<!-- Selector -->
<browser:page
name="multilingual-selector"
diff --git a/src/plone/app/multilingual/browser/helper_views.py b/src/plone/app/multilingual/browser/helper_views.py
index a379c45..34cd0a2 100644
--- a/src/plone/app/multilingual/browser/helper_views.py
+++ b/src/plone/app/multilingual/browser/helper_views.py
@@ -9,6 +9,7 @@
from borg.localrole.interfaces import IFactoryTempFolder
from plone.app.layout.navigation.interfaces import INavigationRoot
from plone.app.multilingual.interfaces import IMultiLanguageExtraOptionsSchema
+from plone.app.multilingual.interfaces import ITG
from plone.app.multilingual.browser.selector import NOT_TRANSLATED_YET_TEMPLATE
from plone.app.multilingual.browser.selector import addQuery
from plone.app.multilingual.interfaces import ILanguageRootFolder
@@ -278,3 +279,11 @@ def language_name(self, lang=None):
if lang_info is None:
return None
return lang_info.get('native', None) or lang_info.get('name')
+
+
+class TGView(BrowserView):
+ """A simple browser view that renders the TG of its context
+ """
+
+ def __call__(self):
+ return str(ITG(self.context, u""))
diff --git a/src/plone/app/multilingual/tests/test_api.py b/src/plone/app/multilingual/tests/test_api.py
index 9776a65..e7d1ce0 100644
--- a/src/plone/app/multilingual/tests/test_api.py
+++ b/src/plone/app/multilingual/tests/test_api.py
@@ -3,6 +3,7 @@
from Products.CMFCore.utils import getToolByName
from plone.app.multilingual import api
from Products.CMFPlone.interfaces import ILanguage
+from plone.app.multilingual.interfaces import ATTRIBUTE_NAME
from plone.app.multilingual.interfaces import ITranslationIdChooser
from plone.app.multilingual.interfaces import ITranslationLocator
from plone.app.multilingual.interfaces import ITranslationManager
@@ -293,3 +294,13 @@ def test_locator(self):

child_locator = ITranslationLocator(subfolder_ca)
self.assertEqual(child_locator('es'), folder_es)
+
+ def test_tg_view(self):
+ a_ca = createContentInContainer(
+ self.portal['ca'],
+ 'Document',
+ title=u"Test document"
+ )
+ tg = getattr(a_ca, ATTRIBUTE_NAME)
+ self.assertTrue(bool(tg))
+ self.assertEqual(a_ca.restrictedTraverse('@@tg')(), tg)
@@ -173,6 +174,20 @@ def set_field_value(self, uid, field, value, field_type):
value = int(value)
if field_type == 'list':
value = eval(value)
+ if field_type.startswith('datetime'):
+ # field_type must begin with 'datetime'
+ # followed by optional format 'datetime%Y%m%d%H%M'
+ # without format: %Y%m%d%H%M is used
+ field_type = field_type[8:]
+ fmt = field_type and field_type or '%Y%m%d%H%M'
+ value = datetime.strptime(value, fmt)
+ if field_type.startswith('date'):
+ # field_type must begin with 'date'
+ # followed by optional format 'date%Y%m%d'
+ # without format: %Y%m%d is used
+ field_type = field_type[4:]
+ fmt = field_type and field_type or '%Y%m%d'
+ value = datetime.strptime(value, fmt).date()
if field_type == 'reference' and HAS_DEXTERITY_RELATIONS:
results_referenced = pc.unrestrictedSearchResults(UID=value)
referenced_obj = results_referenced[0]._unrestrictedGetObject()


0 comments on commit cdeda36

Please sign in to comment.