Skip to content

Commit

Permalink
Merge branch 'issue_24'
Browse files Browse the repository at this point in the history
  • Loading branch information
zupo committed Jan 5, 2013
2 parents 8369207 + 0a5ba84 commit a59276c
Show file tree
Hide file tree
Showing 8 changed files with 358 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/eestec/portal/__init__.py
Expand Up @@ -5,6 +5,7 @@
LC_BOARD_GROUP_STRING = u'%s-board'

CP_LIST_ADDRESS = 'cp@eestec.net'
BOARD_LIST_ADDRESS = 'board@eestec.net'


def initialize(context):
Expand Down
9 changes: 9 additions & 0 deletions src/eestec/portal/content/event.py
Expand Up @@ -2,6 +2,7 @@
"""The event content type. Dexterity is awesome!"""

from Products.CMFCore.interfaces import IActionSucceededEvent
from zope.lifecycleevent import IObjectCreatedEvent
from eestec.portal import emails
from five import grok
from plone.directives import form, dexterity
Expand Down Expand Up @@ -34,3 +35,11 @@ def event_published(context, event):
"""
if event.action == 'publish':
emails.event.published_notify_cp_list(context)
if event.action == 'cancel':
emails.event.cancelled_notify_board(context)
@grok.subscribe(Event, IObjectCreatedEvent)
def event_created(context, event):
"""
Send email to Board list, notifying them that new event was created
"""
emails.event.created_notify_board(context)
63 changes: 63 additions & 0 deletions src/eestec/portal/emails/event.py
Expand Up @@ -2,6 +2,7 @@
"""Emails sent out when stuff happens to Events."""

from eestec.portal import CP_LIST_ADDRESS
from eestec.portal import BOARD_LIST_ADDRESS
from plone import api
from eestec.portal.utils import get_portal_from

Expand Down Expand Up @@ -36,3 +37,65 @@ def published_notify_cp_list(event):
recipient=CP_LIST_ADDRESS,
subject=u'[CP] [EVENTS] %s' % (event.title),
body=body % body_values)

def created_notify_board(event):
"""Send notification email to the Board list, notifying them that a
new Event has been created.
"""

body = u"""
Dear Board,
a new Event has been created on eestec.net:
%(title)s
%(description)s
%(url)s
Best regards,
EESTEC IT Team
"""
body_values = dict(
url=event.absolute_url(),
description=event.description,
title=event.title,
)

api.portal.send_email(
sender=get_portal_from(),
recipient=BOARD_LIST_ADDRESS,
subject=u'[EVENTS][Created] %s' % (event.title),
body=body % body_values)

def cancelled_notify_board(event):
"""Send notification email to the Board list, notifying them that a
new Event has been created.
"""

body = u"""
Dear Board,
an Event has been cancelled on eestec.net:
%(title)s
%(description)s
%(url)s
Best regards,
EESTEC IT Team
"""
body_values = dict(
url=event.absolute_url(),
description=event.description,
title=event.title,
)

api.portal.send_email(
sender=get_portal_from(),
recipient=BOARD_LIST_ADDRESS,
subject=u'[EVENTS][Cancelled] %s' % (event.title),
body=body % body_values)
@@ -0,0 +1,72 @@
"[Workflow]",,,,,,
"Id:","event_application_workflow",,,,,
"Title:","Event Application Workflow",,,,,
"Description:","Workflow for controlling states and permission on the EventApplication content type.",,,,,
"Initial state:","pending",,,,,
"Type:","Workflow",,,,,
,,,,,,
"[State]",,,,,,
"Id:","pending",,,,,
"Title:","Pending",,,,,
"Description:",,,,,,
"Transitions","accept_participant, reject_participant",,,,,
"Permissions","Acquire","Manager","Owner","Reader","Editor","LCBoardMember"
"Access contents information","N","Y","Y","Y","N","Y"
"View","N","Y","Y","Y","N","Y"
"Modify portal content","N","Y","Y","N","Y","N"
"View personal data","N","Y","Y","N","N","Y"
"Confirm participant","Y","Y","N","N","N","N"
,,,,,,
"[State]",,,,,,
"Id:","accepted",,,,,
"Title:","Accepted",,,,,
"Description:",,,,,,
"Transitions","reject_participant, back_to_pending",,,,,
"Permissions","Acquire","Manager","Owner","Reader","Editor","LCBoardMember"
"Access contents information","N","Y","Y","Y","N","Y"
"View","N","Y","Y","Y","N","Y"
"Modify portal content","N","Y","Y","N","Y","N"
"View personal data","N","Y","Y","N","N","Y"
"Confirm participant","Y","Y","N","N","N","N"
,,,,,,
"[State]",,,,,,
"Id:","rejected",,,,,
"Title:","Rejected",,,,,
"Description:",,,,,,
"Transitions","accept_participant, back_to_pending",,,,,
"Permissions","Acquire","Manager","Owner","Reader","Editor","LCBoardMember"
"Access contents information","N","Y","Y","Y","N","Y"
"View","N","Y","Y","Y","N","Y"
"Modify portal content","N","Y","Y","N","Y","N"
"View personal data","N","Y","Y","N","N","Y"
"Confirm participant","Y","Y","N","N","N","N"
,,,,,,
"[Transition]",,,,,,
"Id:","accept_participant",,,,,
"Title:","Accept Participant",,,,,
"Description:",,,,,,
"Details:",,,,,,
"Target state:","accepted",,,,,
"URL:","%(content_url)s/content_status_modify?workflow_action=accept_participant",,,,,
"Trigger:","User",,,,,
"Guard permission:","Confirm participant",,,,,
,,,,,,
"[Transition]",,,,,,
"Id:","reject_participant",,,,,
"Title:","Reject Participant",,,,,
"Description:",,,,,,
"Details:",,,,,,
"Target state:","rejected",,,,,
"URL:","%(content_url)s/content_status_modify?workflow_action=reject_participant",,,,,
"Trigger:","User",,,,,
"Guard permission:","Confirm participant",,,,,
,,,,,,
"[Transition]",,,,,,
"Id:","back_to_pending",,,,,
"Title:","back_to_pending",,,,,
"Description:",,,,,,
"Details:",,,,,,
"Target state:","pending",,,,,
"URL:","%(content_url)s/content_status_modify?workflow_action=back_to_pending",,,,,
"Trigger:","User",,,,,
"Guard permission:","Manage portal",,,,,
164 changes: 164 additions & 0 deletions src/eestec/portal/profiles/default/workflow_csv/event_workflow.csv
@@ -0,0 +1,164 @@
"[Workflow]",,,,,,
"Id:","event_workflow",,,,,
"Title:","Event Workflow",,,,,
"Description:","Workflow for controlling states and permissions on the Event content type.",,,,,
"Initial state:","pending",,,,,
"Type:","Workflow",,,,,
,,,,,,
"[State]",,,,,,
"Id:","pending",,,,,
"Title:","Pending",,,,,
"Description:",,,,,,
"Transitions","publish, cancel",,,,,
"Permissions","Acquire","Manager","LCBoardMember","Reader","Editor","IntBoardMember"
"Access contents information","N","Y","Y","Y","N","Y"
"View","N","Y","Y","Y","N","Y"
"Modify portal content","N","Y","Y","N","Y","N"
"Deadline","N","Y","N","N","N","N"
"eestec.base: Add EventApplication","N","Y","N","N","N","N"
"Confirm participant","N","Y","N","N","N","N"
,,,,,,
"[State]",,,,,,
"Id:","open_for_application",,,,,
"Title:","Open for application",,,,,
"Description:",,,,,,
"Transitions","deadline_reached, back_to_pending, cancel",,,,,
"Permissions","Acquire","Manager","LCBoardMember","Anonymous","Editor","Member"
"Access contents information","N","Y","N","Y","N","N"
"View","N","Y","N","Y","N","N"
"Modify portal content","N","Y","Y","N","Y","N"
"Add portal content","N","Y","Y","N","N","Y"
"eestec.base: Add EventApplication","N","Y","N","N","N","Y"
"Deadline","N","Y","N","N","N","N"
"Confirm participant","N","Y","N","N","N","N"
,,,,,,
"[State]",,,,,,
"Id:","choosing_participants",,,,,
"Title:","Choosing participants",,,,,
"Description:",,,,,,
"Transitions","confirm_participants, back_to_open_for_application, cancel",,,,,
"Permissions","Acquire","Manager","LCBoardMember","Anonymous","Editor",
"Access contents information","N","Y","N","Y","N",
"View","N","Y","N","Y","N",
"Modify portal content","N","Y","Y","N","Y",
"Deadline","N","Y","N","N","N",
"eestec.base: Add EventApplication","N","Y","N","N","N",
"Confirm participant","N","Y","Y","N","N",
,,,,,,
"[State]",,,,,,
"Id:","confirmed",,,,,
"Title:","Confirmed",,,,,
"Description:",,,,,,
"Transitions","accept_more_participants, cancel",,,,,
"Permissions","Acquire","Manager","LCBoardMember","Anonymous","Editor",
"Access contents information","N","Y","N","Y","N",
"View","N","Y","N","Y","N",
"Modify portal content","N","Y","Y","N","Y",
"Deadline","N","Y","N","N","N",
"eestec.base: Add EventApplication","N","Y","N","N","N",
"Confirm participant","N","Y","N","N","N",
,,,,,,
"[State]",,,,,,
"Id:","cancelled",,,,,
"Title:","Cancelled",,,,,
"Description:",,,,,,
"Transitions","back_to_pending, back_to_open_for_application, back_to_choosing_participants, back_to_confirmed",,,,,
"Permissions","Acquire","Manager","LCBoardMember","IntBoardMember","Reader","Editor"
"Access contents information","N","Y","Y","Y","Y","N"
"View","N","Y","Y","Y","Y","N"
"Modify portal content","N","Y","N","N","N","Y"
"Deadline","N","Y","N","N","N","N"
"eestec.base: Add EventApplication","N","Y","N","N","N","N"
"Confirm participant","N","Y","N","N","N","N"
"Add portal content","N","Y","N","N","N","N"
,,,,,,
,,,,,,
"[Transition]",,,,,,
"Id:","publish",,,,,
"Title:","Publish Event",,,,,
"Description:",,,,,,
"Details:",,,,,,
"Target state:","open_for_application",,,,,
"URL:","%(content_url)s/content_status_modify?workflow_action=publish",,,,,
"Trigger:","User",,,,,
"Guard permission:","Modify portal content",,,,,
,,,,,,
"[Transition]",,,,,,
"Id:","deadline_reached",,,,,
"Title:","Deadline reached",,,,,
"Description:","An automatic transition triggered on the day the deadline is reached.",,,,,
"Details:",,,,,,
"Target state:","choosing_participants",,,,,
"URL:","%(content_url)s/content_status_modify?workflow_action=deadline_reached",,,,,
"Trigger:","User",,,,,
"Guard permission:","Deadline",,,,,
,,,,,,
"[Transition]",,,,,,
"Id:","confirm_participants",,,,,
"Title:","Confirm Participants",,,,,
"Description:",,,,,,
"Details:",,,,,,
"Target state:","confirmed",,,,,
"URL:","%(content_url)s/content_status_modify?workflow_action=confirm_participants",,,,,
"Trigger:","User",,,,,
"Guard permission:","Confirm participant",,,,,
,,,,,,
"[Transition]",,,,,,
"Id:","accept_more_participants",,,,,
"Title:","Accept more participants",,,,,
"Description:",,,,,,
"Details:",,,,,,
"Target state:","choosing_participants",,,,,
"URL:","%(content_url)s/content_status_modify?workflow_action=accept_more_participants",,,,,
"Trigger:","User",,,,,
"Guard permission:","Modify portal content",,,,,
,,,,,,
"[Transition]",,,,,,
"Id:","cancel",,,,,
"Title:","Cancel Event",,,,,
"Description:",,,,,,
"Details:",,,,,,
"Target state:","cancelled",,,,,
"URL:","%(content_url)s/content_status_modify?workflow_action=cancel",,,,,
"Trigger:","User",,,,,
"Guard permission:","Modify portal content",,,,,
,,,,,,
"[Transition]",,,,,,
"Id:","back_to_pending",,,,,
"Title:","back_to_pending",,,,,
"Description:",,,,,,
"Details:",,,,,,
"Target state:","pending",,,,,
"URL:","%(content_url)s/content_status_modify?workflow_action=back_to_pending",,,,,
"Trigger:","User",,,,,
"Guard permission:","Manage portal",,,,,
,,,,,,
"[Transition]",,,,,,
"Id:","back_to_open_for_application",,,,,
"Title:","back_to_open_for_application",,,,,
"Description:",,,,,,
"Details:",,,,,,
"Target state:","open_for_application",,,,,
"URL:","%(content_url)s/content_status_modify?workflow_action=back_to_open_for_application",,,,,
"Trigger:","User",,,,,
"Guard permission:","Manage portal",,,,,
,,,,,,
"[Transition]",,,,,,
"Id:","back_to_confirmed",,,,,
"Title:","back_to_confirmed",,,,,
"Description:",,,,,,
"Details:",,,,,,
"Target state:","confirmed",,,,,
"URL:","%(content_url)s/content_status_modify?workflow_action=back_to_confirmed",,,,,
"Trigger:","User",,,,,
"Guard permission:","Manage portal",,,,,
,,,,,,
"[Transition]",,,,,,
"Id:","back_to_published",,,,,
"Title:","back_to_published",,,,,
"Description:",,,,,,
"Details:",,,,,,
"Target state:","published",,,,,
"URL:","%(content_url)s/content_status_modify?workflow_action=back_to_published",,,,,
"Trigger:","User",,,,,
"Guard permission:","Manage portal",,,,,
12 changes: 11 additions & 1 deletion src/eestec/portal/profiles/default/workflows.xml
Expand Up @@ -5,11 +5,21 @@

<bindings>

<!-- Bind LC content types to a dedicated LC workflow -->
<!-- Bind LC content type to a dedicated LC workflow -->
<type type_id="eestec.portal.lc">
<bound-workflow workflow_id="lc_workflow"/>
</type>

<!-- Bind Event content type to a dedicated LC workflow -->
<type type_id="eestec.portal.event">
<bound-workflow workflow_id="event_workflow"/>
</type>

<!-- Bind EventApplication content type to a dedicated LC workflow -->
<type type_id="eestec.portal.eventapplication">
<bound-workflow workflow_id="event_application_workflow"/>
</type>

</bindings>

</object>

0 comments on commit a59276c

Please sign in to comment.