Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ There's a frood who really knows where his towel is.
All Layout tab helper views use now ``collective.cover.CanEditLayout`` permission.
The ``BaseGrid`` class is now located in the ``collective.cover.grids`` module.

- Remove dependency on ``portal_calendar`` tool for calendar tile.
[rodfersou, hvelarde]

- Remove dependency on plone.directives.form.
[l34marr]

Expand Down
2 changes: 1 addition & 1 deletion src/collective/cover/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<metadata>
<version>14</version>
<version>15</version>
<dependencies>
<dependency>profile-collective.js.galleria:default</dependency>
<dependency>profile-collective.js.jqueryui:default</dependency>
Expand Down
19 changes: 6 additions & 13 deletions src/collective/cover/static/css/cover.css
Original file line number Diff line number Diff line change
Expand Up @@ -249,30 +249,23 @@ table.invisible
}

/* Tile Calendar */
.cover-calendar-tile .calendar-tile-header
.cover-calendar-tile .portletCalendar
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rodfersou I think this is a bad idea.

@agnogueira comments?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hvelarde I don't understand your concern here with this css code.. this selector is restrict to our calendar tile because of the .cover-calendar-tile class. It will not affect the portlet calendar.

{
font-weight: bold;
line-height: normal;

padding: .42em 1em;

text-align: center;

background: #ddd;
font-size: 1em;
}
#content .cover-calendar-tile a.calendar-tile-prev,
#content .cover-calendar-tile a.calendar-tile-next
#content .cover-calendar-tile a.calendarPrevious,
#content .cover-calendar-tile a.calendarNext
{
margin: 0 -.5em;
padding: 0 1em;

border-bottom: none;
}
.cover-calendar-tile a.calendar-tile-prev
.cover-calendar-tile a.calendarPrevious
{
float: left;
}
.cover-calendar-tile a.calendar-tile-next
.cover-calendar-tile a.calendarNext
{
float: right;
}
53 changes: 50 additions & 3 deletions src/collective/cover/static/js/main.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,61 @@
$(function() {
// override jquery portlet event
// http://stackoverflow.com/a/14063574/2116850
function refreshPortlet(hash, _options){
var options = {
data: {},
success: function(){},
error: function(){},
ajaxOptions: {}};
$.extend(options, _options);
options.data.portlethash = hash;
ajaxOptions = options.ajaxOptions;
ajaxOptions.url = $('base').attr('href') + '/@@render-portlet';
ajaxOptions.success = function(data){
var container = $('[data-portlethash="' + hash + '"]');
var portlet = $(data);
container.html(portlet);
options.success(data, portlet);
}
ajaxOptions.error = function(){
options.error();
}
ajaxOptions.data = options.data;
$.ajax(ajaxOptions);
}
$('body').undelegate('#calendar-next, #calendar-previous', 'click')
.delegate(
'.portletWrapper #calendar-next, ' +
'.portletWrapper #calendar-previous',
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this override, I just set the selector to target just portlets with the .portletWrapper class (maybe we should create a PR for plone.app.portlets package)

Copy link
Copy Markdown
Member

@hvelarde hvelarde Aug 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rodfersou maybe you can avoid that using a different selector.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hvelarde the problem here is that I am getting the html from the portlet without change, this has the benefit to don't have to maintain this code, but the javascript from this portlet has this problem, the selector to refresh portlet is looking out of the portlet too. It would be no problem if there were a <div> with class .portletWrapper and the portlet id as data attribute to make it work with the original javascript of the portlet, but we don't have it.

'click',
function(e) {
e.preventDefault();
var el = $(this);
var container = el.parents('.portletWrapper');
refreshPortlet(container.data('portlethash'), {
data: {
month: el.data('month'),
year: el.data('year')
}
});
return false;
});
// override jquery portlet event

$('#content').on(
'click',
'.cover-calendar-tile a.calendar-tile-prev, ' +
'.cover-calendar-tile a.calendar-tile-next',
'.cover-calendar-tile .calendarPrevious, ' +
'.cover-calendar-tile .calendarNext',
function(e) {
e.preventDefault();
var $a = $(this);
var $tile = $a.parents('.tile');
var url = '@@updatetile'
if ($a.hasClass('kssCalendarChange')) {
url = $a.attr('href');
}
$.ajax({
url: '@@updatetile',
url: url,
data: {
'tile-id': $tile.attr('id'),
'month:int': $a.attr('data-month'),
Expand Down
1 change: 0 additions & 1 deletion src/collective/cover/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ def setUpPloneSite(self, portal):
set_image_field(portal['my-image1'], generate_jpeg(50, 50))
set_image_field(portal['my-image2'], generate_jpeg(50, 50))
set_image_field(portal['my-news-item'], generate_jpeg(50, 50))

portal_workflow = portal.portal_workflow
portal_workflow.setChainForPortalTypes(
['Collection'], ['simple_publication_workflow'])
Expand Down
11 changes: 0 additions & 11 deletions src/collective/cover/tests/test_calendar_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def setUp(self):
self.tile.__name__ = u'collective.cover.calendar'
self.tile.id = u'test'

@unittest.expectedFailure # FIXME: raises BrokenImplementation
def test_interface(self):
self.interface = ICalendarTile
self.klass = CalendarTile
Expand All @@ -27,13 +26,3 @@ def test_default_configuration(self):

def test_accepted_content_types(self):
self.assertEqual(self.tile.accepted_ct(), [])


# load tests only in Plone < 5
def test_suite():
# FIXME: https://github.com/collective/collective.cover/issues/633
from collective.cover.config import IS_PLONE_5
if IS_PLONE_5:
return unittest.TestSuite()

return unittest.defaultTestLoader.loadTestsFromName(__name__)
40 changes: 32 additions & 8 deletions src/collective/cover/tests/test_calendar_tile.robot
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,44 @@ Test Calendar Tile
# test next / prev buttons
${nextyear} = Execute Javascript
... return (function() {
... var $next = jQuery('a.calendar-tile-next');
... var $next = jQuery('a.calendarNext');
... var str_klasses = $next.attr('class');
... if (str_klasses.indexOf('kssattr') >= 0) {
... var klasses = str_klasses.split(' ');
... var i, klass, len, year, year_check;
... for (i = 0, len = klasses.length; i < len; i++) {
... klass = klasses[i];
... year_check = 'kssattr-year-';
... if (klass.indexOf(year_check) === 0) {
... return klass.slice(year_check.length);
... }
... }
... }
... return $next.attr('data-year');
... })();
${nextmonth} = Execute Javascript
... return (function() {
... var $next = jQuery('a.calendar-tile-next');
... var $next = jQuery('a.calendarNext');
... var str_klasses = $next.attr('class');
... if (str_klasses.indexOf('kssattr') >= 0) {
... var klasses = str_klasses.split(' ');
... var i, klass, len, month, month_check;
... for (i = 0, len = klasses.length; i < len; i++) {
... klass = klasses[i];
... month_check = 'kssattr-month-';
... if (klass.indexOf(month_check) === 0) {
... return klass.slice(month_check.length);
... }
... }
... }
... return $next.attr('data-month');
... })();
Wait Until Keyword Succeeds 5 sec 1 sec Click Link css=a.calendar-tile-next
Wait Until Keyword Succeeds 5 sec 1 sec Click Link css=a.calendar-tile-next
Page Should Contain Element xpath=.//a[@class='calendar-tile-prev'][@data-month='${nextmonth}'][@data-year='${nextyear}']
Wait Until Keyword Succeeds 5 sec 1 sec Click Link css=a.calendar-tile-prev
Wait Until Keyword Succeeds 5 sec 1 sec Click Link css=a.calendar-tile-prev
Page Should Contain Element xpath=.//a[@class='calendar-tile-next'][@data-month='${nextmonth}'][@data-year='${nextyear}']
Wait Until Keyword Succeeds 5 sec 1 sec Click Link css=a.calendarNext
Wait Until Keyword Succeeds 5 sec 1 sec Click Link css=a.calendarNext
Page Should Contain Element jquery=a.calendarPrevious[data-month=${nextmonth}][data-year=${nextyear}],a.calendarPrevious.kssattr-month-${nextmonth}.kssattr-year-${nextyear}
Wait Until Keyword Succeeds 5 sec 1 sec Click Link css=a.calendarPrevious
Wait Until Keyword Succeeds 5 sec 1 sec Click Link css=a.calendarPrevious
Page Should Contain Element jquery=a.calendarNext[data-month=${nextmonth}][data-year=${nextyear}],a.calendarNext.kssattr-month-${nextmonth}.kssattr-year-${nextyear}

# delete the tile
Open Layout Tab
Expand Down
12 changes: 11 additions & 1 deletion src/collective/cover/tests/test_upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,6 @@ def test_registrations(self):
self.assertGreaterEqual(int(version), int(self.to_version))
self.assertEqual(self._how_many_upgrades_to_do(), 4)

# FIXME: https://github.com/collective/collective.cover/issues/633
@unittest.skipIf(IS_PLONE_5, 'Upgrade step not supported under Plone 5')
def test_register_calendar_tile(self):
# address also an issue with Setup permission
Expand Down Expand Up @@ -577,3 +576,14 @@ def test_register_calendar_script(self):
self._do_upgrade_step(step)

self.assertIn(script, js_tool.getResourceIds())


class Upgrade14to15TestCase(UpgradeTestCaseBase):

def setUp(self):
UpgradeTestCaseBase.setUp(self, u'14', u'15')

def test_registrations(self):
version = self.setup.getLastVersionForProfile(self.profile_id)[0]
self.assertGreaterEqual(int(version), int(self.to_version))
self.assertEqual(self._how_many_upgrades_to_do(), 2)
9 changes: 0 additions & 9 deletions src/collective/cover/tests/test_vocabularies.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from collective.cover.config import IS_PLONE_5
from collective.cover.controlpanel import ICoverSettings
from collective.cover.testing import INTEGRATION_TESTING
from plone.registry.interfaces import IRegistry
Expand Down Expand Up @@ -46,10 +45,6 @@ def test_available_tiles_vocabulary(self):
'collective.cover.richtext',
]

# FIXME: https://github.com/collective/collective.cover/issues/633
if IS_PLONE_5:
expected.remove('collective.cover.calendar')

self.assertEqual(len(tiles), len(expected))
for i in expected:
self.assertIn(i, tiles)
Expand All @@ -73,10 +68,6 @@ def test_enabled_tiles_vocabulary(self):
'collective.cover.richtext',
]

# FIXME: https://github.com/collective/collective.cover/issues/633
if IS_PLONE_5:
expected.remove('collective.cover.calendar')

self.assertEqual(len(tiles), len(expected))
for i in expected:
self.assertIn(i, tiles)
Expand Down
Loading