Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
laulaz committed Oct 11, 2024
1 parent 889ce5f commit 62c8819
Show file tree
Hide file tree
Showing 69 changed files with 388 additions and 390 deletions.
14 changes: 13 additions & 1 deletion base.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package-name = collective.contact.core
package-extras = [test]
extends =
https://raw.github.com/collective/buildout.plonetest/master/test-4.3.x.cfg
https://raw.github.com/collective/buildout.plonetest/master/test-6.0.x.cfg
https://raw.github.com/collective/buildout.plonetest/master/qa.cfg
sources.cfg
checkouts.cfg
Expand All @@ -13,6 +13,12 @@ show-picked-versions = true
parts +=
omelette

auto-checkout =
collective.contact.widget
plone.formwidget.masterselect
plone.formwidget.autocomplete
plone.formwidget.contenttree

[test]
eggs +=
ipdb
Expand All @@ -30,3 +36,9 @@ flake8-extensions =
[omelette]
recipe = collective.recipe.omelette
eggs = ${instance:eggs}

[sources]
collective.contact.widget = git git@github.com:collective/collective.contact.widget branch=python3
plone.formwidget.masterselect = git git@github.com:collective/plone.formwidget.masterselect.git branch=plone6_compatibility
plone.formwidget.autocomplete = git git@github.com:plone/plone.formwidget.autocomplete.git
plone.formwidget.contenttree = git git@github.com:plone/plone.formwidget.contenttree.git
2 changes: 1 addition & 1 deletion checkouts.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[buildout]
extends =
https://raw.github.com/plone/buildout.coredev/4.3/sources.cfg
https://raw.github.com/plone/buildout.coredev/6.0/sources.cfg
always-checkout = force
auto-checkout +=
collective.contact.widget
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pip==20.3.4
setuptools==44.1.1
zc.buildout==2.13.3
wheel
pip==24.2
setuptools==74.0.0
zc.buildout==3.1.0
wheel==0.44.0
16 changes: 4 additions & 12 deletions src/collective/contact/core/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,9 @@ def get_vcard(self):
return vcard


def sort_closed_positions(position1, position2):
if position1.end_date == position2.end_date:
return 0
elif not position1.end_date:
# position without end date is greater
return 1
elif not position2.end_date:
return -1
else:
return cmp(position1.end_date, position2.end_date)

def closed_position_sort_key(position):
return position.end_date or float('inf')


@implementer(IPersonHeldPositions)
class PersonHeldPositionsAdapter(object):
Expand Down Expand Up @@ -205,7 +197,7 @@ def get_closed_positions(self):
all_positions = self.person.get_held_positions()
active_positions = self.get_current_positions()
closed_positions = [p for p in all_positions if p not in active_positions]
closed_positions.sort(cmp=sort_closed_positions, reverse=True)
closed_positions.sort(key=closed_position_sort_key, reverse=True)
return tuple(closed_positions)

def get_sorted_positions(self):
Expand Down
9 changes: 5 additions & 4 deletions src/collective/contact/core/browser/addcontact.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ def add_contact_infos(self, widget):
return {'actions': actions,
'close_on_click': close_on_click,
'formatItem': """function(row, idx, count, value) {
return '<img src="' + portal_url + '/' + row[2] + '_icon.png'
return '<img src="' + $("body").data("portal-url") + '/' + row[2] + '_icon.png'
+'" /> ' + row[1] }"""
}
} # TODO


@implementer(IContentProvider)
Expand Down Expand Up @@ -210,7 +210,7 @@ def render(self):
add_text = addneworga.data('pbo').original_text;
} else {
// update add new orga link to add sub orga
add_organization_url = portal_url + orga.path + '/++add++organization';
add_organization_url = $("body").data("portal-url") + orga.path + '/++add++organization';
add_text = addneworga.data('pbo').original_text + ' dans ' + orga.title;
}
addneworga.data('pbo').src = add_organization_url;
Expand All @@ -225,7 +225,7 @@ def render(self):
.setOptions({extraParams: {path: orga.token}}).flushCache();
// update add new position url
var add_position_url = portal_url + orga.path + '/++add++position';
var add_position_url = $("body").data("portal-url") + orga.path + '/++add++position';
o.find('#oform-widgets-position-autocomplete .addnew').each(function(){
jQuery(this).data('pbo').src = add_position_url;
})
Expand Down Expand Up @@ -258,6 +258,7 @@ def render(self):
});
</script>
""" % str(bool(getattr(self.__parent__.form, 'schema', None) == IAddHeldPosition)).lower()
# TODO


class IAddHeldPosition(model.Schema):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
i18n:domain="collective.contact.core"
tal:define="ajax_load request/ajax_load | nothing;">
tal:define="icons python:context.restrictedTraverse('@@iconresolver');
ajax_load request/ajax_load | nothing;">

<h1 class="heldpos"><img tal:attributes="src context/getIconURL" /> <span tal:content="view/title" /></h1>
<h1 class="heldpos">
<tal:icon
tal:define="icon_name context/getIconURL"
tal:replace="structure python:icons.tag(icon_name)" />
<span tal:content="view/title" />
</h1>

<div id="viewlet-below-content-title" tal:content="structure provider:plone.belowcontenttitle"
tal:condition="python: view.display_below_content_title() and not ajax_load" />
Expand All @@ -17,7 +23,10 @@

<div class="field" tal:condition="view/position">
<label><tal:block i18n:translate="">Position</tal:block>:</label>
<img tal:attributes="src view/position/getIconURL" /> <a class="link-tooltip" tal:attributes="href view/position/absolute_url">
<tal:icon
tal:define="icon_name view/position/getIconURL"
tal:replace="structure python:icons.tag(icon_name)" />
<a class="link-tooltip" tal:attributes="href view/position/absolute_url">
<span tal:content="view/position/Title"
i18n:translate="" />
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
i18n:domain="collective.contact.core" tal:omit-tag=""
tal:define="ajax_load request/ajax_load | nothing;">
tal:define="icons python:context.restrictedTraverse('@@iconresolver');
ajax_load request/ajax_load | nothing;">

<h1 class="org"><img tal:attributes="src context/getIconURL" /> <span tal:content="view/name" /></h1>
<h1 class="org">
<tal:icon
tal:define="icon_name context/getIconURL"
tal:replace="structure python:icons.tag(icon_name)" />
<span tal:content="view/name" />
</h1>

<div id="viewlet-below-content-title" tal:content="structure provider:plone.belowcontenttitle"
tal:condition="python: view.display_below_content_title() and not ajax_load" />

<div metal:use-macro="context/kss_generic_macros/macros/generic_description_view">
Generic KSS Description. Is rendered with class="documentDescription".
</div>

<div id="logo" class="field" tal:condition="context/logo">
<img tal:define="scales nocall:context/@@images"
Expand Down
24 changes: 16 additions & 8 deletions src/collective/contact/core/browser/basefields/templates/person.pt
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,28 @@
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
tal:define="portal_url context/@@plone_portal_state/portal_url;
tal:define="icons python:context.restrictedTraverse('@@iconresolver');
portal_url context/@@plone_portal_state/portal_url;
ajax_load request/ajax_load | nothing;"
i18n:domain="collective.contact.core" tal:omit-tag="">

<div class="actions">
<a class="edit-person contactoverlay" tal:attributes="href string:${context/absolute_url}/edit">
<img alt="Edit" title="Edit"
tal:attributes="src string:${portal_url}/edit.png"
tal:condition="view/can_edit"
i18n:domain="plone"
i18n:attributes="alt; title" />
<a class="edit-person contactoverlay pat-plone-modal"
tal:attributes="href string:${context/absolute_url}/edit"
title="Edit"
i18n:domain="plone"
i18n:attributes="title">
<tal:icon
tal:replace="structure python:icons.tag('pencil-fill')"
tal:condition="view/can_edit" />
</a>
</div>
<h1 class="fn"><img tal:attributes="src context/getIconURL" /> <span tal:content="view/name" /></h1>
<h1 class="fn">
<tal:icon
tal:define="icon_name context/getIconURL"
tal:replace="structure python:icons.tag(icon_name)" />
<span tal:content="view/name" />
</h1>

<div id="viewlet-below-content-title" tal:content="structure provider:plone.belowcontenttitle"
tal:condition="python: view.display_below_content_title() and not ajax_load" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
i18n:domain="collective.contact.core" tal:omit-tag=""
tal:define="ajax_load request/ajax_load | nothing;">
tal:define="icons python:context.restrictedTraverse('@@iconresolver');
ajax_load request/ajax_load | nothing;">

<h1 class="pos"><img tal:attributes="src context/getIconURL" /> <span tal:content="view/name" /></h1>
<h1 class="pos">
<tal:icon
tal:define="icon_name context/getIconURL"
tal:replace="structure python:icons.tag(icon_name)" />
<span tal:content="view/name" />
</h1>

<div id="viewlet-below-content-title" tal:content="structure provider:plone.belowcontenttitle"
tal:condition="python: view.display_below_content_title() and not ajax_load" />
Expand Down
8 changes: 4 additions & 4 deletions src/collective/contact/core/browser/basefields/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def display_below_content_title(self):
default=False)


class PersonBaseFields(BrowserView):
class PersonBaseFields(BrowserView, BaseFields):
name = ''
birthday = ''
person_title = ''
Expand Down Expand Up @@ -52,7 +52,7 @@ def __call__(self):
return super(PersonBaseFields, self).__call__()


class OrganizationBaseFields(BrowserView):
class OrganizationBaseFields(BrowserView, BaseFields):
name = ''
type = ''
positions = []
Expand All @@ -76,7 +76,7 @@ def __call__(self):
return super(OrganizationBaseFields, self).__call__()


class PositionBaseFields(BrowserView):
class PositionBaseFields(BrowserView, BaseFields):
name = ''
type = ''

Expand All @@ -93,7 +93,7 @@ def __call__(self):
return super(PositionBaseFields, self).__call__()


class HeldPositionBaseFields(BrowserView):
class HeldPositionBaseFields(BrowserView, BaseFields):
start_date = ''
end_date = ''
birthday = ''
Expand Down
9 changes: 8 additions & 1 deletion src/collective/contact/core/browser/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
name="view"
for="..interfaces.IHeldPosition"
class=".contact.Contact"
allowed_attributes="parent_organizations sub_organizations positions can_add addnew_script"
allowed_attributes="parent_organizations sub_organizations positions can_add"
template="templates/contact.pt"
permission="zope2.View"
/>
Expand Down Expand Up @@ -162,6 +162,13 @@
permission="zope2.View"
/>

<browser:page
name="contact_core_macros"
for="*"
template="templates/contact_core_macros.pt"
permission="zope2.View"
/>

<adapter
for="*"
factory=".contactable.ContactDetailsContactable"
Expand Down
25 changes: 4 additions & 21 deletions src/collective/contact/core/browser/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,6 @@
from Products.Five import BrowserView


ADDNEW_OVERLAY = """
<script type="text/javascript">
$(document).ready(function(){
$('.addnewcontactfromorganization').prepOverlay({
subtype: 'ajax',
filter: common_content_filter,
formselector: '#oform',
cssclass: 'overlay-contact-addnew',
closeselector: '[name="oform.buttons.cancel"]',
noform: function(el, pbo) {return 'reload';},
config: {
closeOnClick: false,
closeOnEsc: false
}
});
});
</script>
"""


class Organization(BaseView):

def update(self):
Expand All @@ -51,7 +31,6 @@ def update(self):
self.positions = self.context.get_positions()
sm = getSecurityManager()
self.can_add = sm.checkPermission('Add portal content', self.context)
self.addnew_script = ADDNEW_OVERLAY

def display_date(self, date):
"""Display date nicely in template."""
Expand All @@ -75,6 +54,10 @@ class OtherContacts(BrowserView):
held_positions = ''

def __call__(self):
self.update()
return super(OtherContacts, self).__call__()

def update(self):
organization = self.context
othercontacts = []
held_positions = organization.get_held_positions()
Expand Down
5 changes: 4 additions & 1 deletion src/collective/contact/core/browser/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from collective.contact.core.interfaces import IContactable
from collective.contact.core.interfaces import IPersonHeldPositions
from Products.Five import BrowserView
from zope.component import queryMultiAdapter


class Person(BaseView):
Expand Down Expand Up @@ -47,7 +48,9 @@ def __call__(self):
# held_position['email'] = obj.email
held_position['object'] = obj
organization = obj.get_organization()
held_position['icon'] = obj.getIconURL()

icons = queryMultiAdapter((obj, self.request), name="iconresolver")
held_position['icon'] = icons.url("file-earmark-person-fill")
held_position['organization'] = organization if organization else None
held_position['can_edit'] = sm.checkPermission('Modify portal content', obj)
held_position['can_delete'] = sm.checkPermission('Delete objects', obj)
Expand Down
21 changes: 0 additions & 21 deletions src/collective/contact/core/browser/position.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,6 @@
from zope.schema.interfaces import IVocabularyFactory


ADDNEW_OVERLAY = """
<script type="text/javascript">
$(document).ready(function(){
$('.addnewcontactfromposition').prepOverlay({
subtype: 'ajax',
filter: common_content_filter,
formselector: '#oform',
cssclass: 'overlay-contact-addnew',
closeselector: '[name="oform.buttons.cancel"]',
noform: function(el, pbo) {return 'reload';},
config: {
closeOnClick: false,
closeOnEsc: false
}
});
});
</script>
"""


class Position(BaseView):

def update(self):
Expand All @@ -40,4 +20,3 @@ def update(self):

sm = getSecurityManager()
self.can_add = sm.checkPermission('Add portal content', self.context)
self.addnew_script = ADDNEW_OVERLAY
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 62c8819

Please sign in to comment.