class AddForm(base.NullAddForm):
    form_fields = form.Fields(IMissionFacilityNavigation)
    label = _(u"Add Mission Facility Navigation")
    description = _(u"Navigation for Mission Facilities")

    def create(self):
        return Assignment()
class FundingSources(grok.GlobalUtility):
    grok.name('ploneun.missions.funding_sources')
    grok.implements(IVocabularyFactory)

    _terms = [{
        'value': u'Multilateral',
        'title': _(u'Term Title'),
    }, {
        'value': u'Bilateral',
        'title': _(u'Bilateral')
    }, {
        'value': u'Private Sector',
        'title': _(u'Private Sector')
    }, {
        'value': u'Financial Instituition',
        'title': _(u'Financial Instituition')
    }, {
        'value': u'Government',
        'title': _(u'Government')
    }, {
        'value': u'CSO',
        'title': _(u'CSO')
    }, {
        'value': u'Non-Profit Foundation',
        'title': _(u'Non-Profit Foundation')
    }]

    def __call__(self, context):
        terms = []
        for i in self._terms:
            terms.append(SimpleTerm(**i))
        return SimpleVocabulary(terms)
 def links(self):
     facility = self.facility()
     url = facility.absolute_url()
     return [{
         'id': 'add-mission',
         'title': _('Add Mission'),
         'url': '%s/missions/++add++ploneun.missions.mission' % url
     },{
         'id': 'view-all',
         'title': _('View All Missions'),
         'url': '%s/all-missions' % url
     },{
         'id': 'view-travel-table',
         'title': _('View All Missions (Table)'),
         'url': '%s/all-missions/missiontravel' % url
     },{
         'id': 'view-mission-reports',
         'title': _('View All Mission Reports'),
         'url': '%s/all-missionreports' % url
     },{
         'id': 'view-my-missions',
         'title': _('My Missions'),
         'url': '%s/my-missions' % url
     },{
         'id': 'view-my-missionreport',
         'title': _('My Mission Reports'),
         'url': '%s/my-missionreports' % url
     },{
         'id': 'view-my-missionreport-drafts',
         'title': _('My Mission Report Drafts'),
         'url': '%s/my-missionreport-drafts' % url
     },{
         'id': 'view-my-missions-without-reports',
         'title': _('My Missions Without Reports'),
         'url': '%s/my-missions-without-reports' % url,
     },{
         'id': 'search-missions',
         'title': _(u'Search Missions'),
         'url': '%s/search-missions' % url
     },{
         'id': 'search-missionreports',
         'title': _(u'Search Mission Reports'),
         'url': '%s/search-missionreports' % url,
     }]
 def links(self):
     facility = self.facility()
     url = facility.absolute_url()
     return [{
         'id': 'add-mission',
         'title': _('Add Mission'),
         'url': '%s/missions/++add++ploneun.missions.mission' % url
     }, {
         'id': 'view-all',
         'title': _('View All Missions'),
         'url': '%s/all-missions' % url
     }, {
         'id': 'view-travel-table',
         'title': _('View All Missions (Table)'),
         'url': '%s/all-missions/missiontravel' % url
     }, {
         'id': 'view-mission-reports',
         'title': _('View All Mission Reports'),
         'url': '%s/all-missionreports' % url
     }, {
         'id': 'view-my-missions',
         'title': _('My Missions'),
         'url': '%s/my-missions' % url
     }, {
         'id': 'view-my-missionreport',
         'title': _('My Mission Reports'),
         'url': '%s/my-missionreports' % url
     }, {
         'id': 'view-my-missionreport-drafts',
         'title': _('My Mission Report Drafts'),
         'url': '%s/my-missionreport-drafts' % url
     }, {
         'id': 'view-my-missions-without-reports',
         'title': _('My Missions Without Reports'),
         'url': '%s/my-missions-without-reports' % url,
     }, {
         'id': 'search-missions',
         'title': _(u'Search Missions'),
         'url': '%s/search-missions' % url
     }, {
         'id': 'search-missionreports',
         'title': _(u'Search Mission Reports'),
         'url': '%s/search-missionreports' % url,
     }]
class MissionScope(grok.GlobalUtility):
    grok.name('ploneun.missions.mission_scope')
    grok.implements(IVocabularyFactory)

    _terms = [{
        'value': u'International',
        'title': _(u'International'),
    }, {
        'value': u'National',
        'title': _(u'National'),
    }, {
        'value': u'Regional',
        'title': _(u'Regional')
    }]

    def __call__(self, context):
        terms = []
        for i in self._terms:
            terms.append(SimpleTerm(**i))
        return SimpleVocabulary(terms)
from collective.grok import gs
from ploneun.missions import MessageFactory as _

@gs.importstep(
    name=u'ploneun.missions', 
    title=_('ploneun.missions import handler'),
    description=_(''))
def setupVarious(context):
    if context.readDataFile('ploneun.missions.marker.txt') is None:
        return
    portal = context.getSite()

    # do anything here

    portal.portal_catalog.reindexIndex('ploneun_missionscope', portal.REQUEST)
    portal.portal_catalog.reindexIndex('ploneun_country', portal.REQUEST)
    portal.portal_catalog.reindexIndex('ploneun_country', portal.REQUEST)
from collective.grok import gs
from ploneun.missions import MessageFactory as _


@gs.importstep(name=u"ploneun.missions", title=_("ploneun.missions import handler"), description=_(""))
def setupVarious(context):
    if context.readDataFile("ploneun.missions.marker.txt") is None:
        return
    portal = context.getSite()

    # do anything here

    portal.portal_catalog.reindexIndex("ploneun_missionscope", portal.REQUEST)
    portal.portal_catalog.reindexIndex("ploneun_country", portal.REQUEST)
    portal.portal_catalog.reindexIndex("ploneun_country", portal.REQUEST)
    portal.portal_catalog.reindexIndex("mission_type", portal.REQUEST)
class IMissionReport(form.Schema, IImageScaleTraversable):
    """
    UN Mission Report
    """
    title = schema.TextLine(title=u'Mission Title', required=True)

    overall_objective = schema.Text(title=u'Overall Objective', required=True)

    #    dexteritytextindexer.searchable('report_outcome')
    #    report_outcome = schema.TextLine(
    #        title=_(u'Country / Regional Programme Outcome'),
    #        description=_(u'Enter outcome code here eg. IDN 101'),
    #        required=False
    #    )

    #    dexteritytextindexer.searchable('report_outcome_text')
    #    form.widget(report_outcome_text="plone.app.z3cform.wysiwyg.WysiwygFieldWidget")
    #    report_outcome_text = schema.Text(
    #        title=_(u'Contribution to Outcome'),
    #        description=_(u'Please describe briefly how your mission has'
    #            'contributed to realizing the relevant country/regional outcome.'),
    #        required=False
    #    )

    #    dexteritytextindexer.searchable('report_author')
    #    form.widget(report_author=AutocompleteMultiFieldWidget)
    #    report_author= schema.List(
    #        title=_(u'Author(s)'),
    #        description=_(u'List of Authors. Enter '
    #            'name to search, select and press Enter to add. Repeat to '
    #            'to add additional members with principal author first.'),
    #        value_type=schema.Choice(vocabulary=u"plone.principalsource.Users"),
    #        default=[],
    #        missing_value=(),
    #        required=True,
    #    )

    report_author = schema.Text(title=u'Author(s)', required=True)

    mission_members = schema.Text(title=u'Mission Members',
                                  description=_(u'List of Mission Members.'),
                                  required=True)

    #    dexteritytextindexer.searchable('mission_members')
    #    form.widget(mission_members=AutocompleteMultiFieldWidget)
    #    mission_members= schema.List(
    #        title=_(u'Mission Members'),
    #        description=_(u'List of Mission Members.'),
    #        value_type=schema.Choice(vocabulary=u"plone.principalsource.Users",),
    #        required=True,
    #    )

    #ILO Office

    startDate = schema.Date(title=_(u'Mission Start date'), )

    endDate = schema.Date(title=_(u'Mission End date'), )

    dexteritytextindexer.searchable('mission_type')
    form.widget(mission_type=RadioFieldWidget)
    mission_type = schema.Choice(title=_(u'Mission Type'),
                                 vocabulary=MissionType,
                                 required=True)

    dexteritytextindexer.searchable('mission_city')
    mission_city = schema.TextLine(title=_(u'City'), required=False)

    #Mission Location

    #Other

    #ILO themes

    #Theme

    mission_location_other = schema.TextLine(
        title=_(u'Other'),
        description=_(
            u'If Other was selected, please specify country location.'),
        required=False,
    )

    dexteritytextindexer.searchable('achievements_summary')
    form.widget(
        achievements_summary="plone.app.z3cform.wysiwyg.WysiwygFieldWidget")
    achievements_summary = schema.Text(
        title=_(u'Summary of Main Achievements'),
        description=_(u'Please fill this section in short telex style'),
        required=False)

    dexteritytextindexer.searchable('mission_findings')
    form.widget(
        mission_findings="plone.app.z3cform.wysiwyg.WysiwygFieldWidget")
    mission_findings = schema.Text(
        title=_(u'Mission Findings'),
        description=_(
            u'Please keep to approx 500 words. Other relevant documents'
            ' can be attached below.'),
        required=False)

    dexteritytextindexer.searchable('mission_followup')
    form.widget(
        mission_followup="plone.app.z3cform.wysiwyg.WysiwygFieldWidget")
    mission_followup = schema.Text(
        title=_(u'Follow-up actions/next steps'),
        description=_(u'In point form, include who should be doing what. '
                      u'One follow-up action per line.'),
        required=False)

    dexteritytextindexer.searchable('mission_contact')
    form.widget(mission_contact="plone.app.z3cform.wysiwyg.WysiwygFieldWidget")
    mission_contact = schema.Text(
        title=_(u'List of Contacts'),
        description=_(u'List of professionals and/or organizations met with '
                      u'during the mission'),
        required=False)

    #    mission_distribution = schema.Text(
    #        title=u'Distribution List (Members)',
    #        description=_(u'Comma separated list of who a copy of this mission report should be sent to. Select previous email addresses from drop down list, or type new email address followed by a comma. Copy will be sent, when Mission Report state is submitted.'),
    #        required=True
    #    )

    #    mission_distribution_others = schema.Text(
    #        title=u'Distribution List (Others)',
    #        description=_(u'Comma separated list of who a copy of this mission report should be sent to. Select previous email addresses from drop down list, or type new email address followed by a comma. Copy will be sent, when Mission Report state is submitted.'),
    #        required=True
    #    )

    dexteritytextindexer.searchable('mission_distribution')
    form.widget(mission_distribution=AutocompleteMultiFieldWidget)
    mission_distribution = schema.List(
        title=_(u'Distribution List (Members)'),
        description=_(u'Enter name to search, select and press Enter to add. '
                      'Repeat to add additional members'),
        value_type=schema.Choice(vocabulary='plone.principalsource.Users'),
        required=False)

    dexteritytextindexer.searchable('mission_distribution_others')
    mission_distribution_others = schema.List(
        title=_(u'Distribution List (Others)'),
        description=
        _(u'Add email addreses of unregistered members here.  One address for each line'
          ),
        required=False,
        value_type=schema.TextLine())

    attachment1 = NamedBlobFile(
        title=_(u"Attachment 1"),
        description=_(u"Please attach a file"),
        required=False,
    )

    attachment2 = NamedBlobFile(
        title=_(u"Attachment 2"),
        description=_(u"Please attach a file"),
        required=False,
    )

    attachment3 = NamedBlobFile(
        title=_(u"Attachment 3"),
        description=_(u"Please attach a file"),
        required=False,
    )

    attachment4 = NamedBlobFile(
        title=_(u"Attachment 4"),
        description=_(u"Please attach a file"),
        required=False,
    )

    attachment5 = NamedBlobFile(
        title=_(u"Attachment 5"),
        description=_(u"Please attach a file"),
        required=False,
    )

    @invariant
    def formValidation(self):
        if self.startDate > self.endDate:
            raise Invalid(u"Start date should not be later than end date.")
        if self.mission_distribution_others:
            for mdo in self.mission_distribution_others:
                if not validateaddress(mdo):
                    raise Invalid(
                        u"One the addresess in Distribution List (Others) is not a valid email address, or addresses were not line separated."
                    )
from Products.CMFDefault.exceptions import EmailAddressInvalid

#from z3c.form.interfaces import HIDDEN_MODE
import z3c.form


def validateaddress(value):
    try:
        checkEmailAddress(value)
    except EmailAddressInvalid:
        return False
    return True


MissionType = SimpleVocabulary([
    SimpleTerm(value=u'Domestic', title=_(u'Domestic')),
    SimpleTerm(value=u'International', title=_(u'International'))
])

# Interface class; used to define content-type schema.


class IMissionReport(form.Schema, IImageScaleTraversable):
    """
    UN Mission Report
    """
    title = schema.TextLine(title=u'Mission Title', required=True)

    overall_objective = schema.Text(title=u'Overall Objective', required=True)

    #    dexteritytextindexer.searchable('report_outcome')
Example #10
0
from plone.z3cform.fieldsets.utils import move
from Products.CMFDefault.utils import checkEmailAddress
from Products.CMFDefault.exceptions import EmailAddressInvalid

#from z3c.form.interfaces import HIDDEN_MODE
import z3c.form

def validateaddress(value):
    try:
        checkEmailAddress(value)
    except EmailAddressInvalid:
        return False
    return True

MissionType = SimpleVocabulary(
    [SimpleTerm(value=u'Domestic', title=_(u'Domestic')),
     SimpleTerm(value=u'International', title=_(u'International'))]
    )

# Interface class; used to define content-type schema.

class IMissionReport(form.Schema, IImageScaleTraversable):
    """
    UN Mission Report
    """
    title = schema.TextLine(
        title=u'Mission Title',
        required=True
    )

    overall_objective = schema.Text(
 def start_end_dates_validation(self):
     if self.startDate and self.endDate:
         if self.endDate < self.startDate:
             raise Invalid(_("End date should not be earlier than start date."))
Example #12
0
 def start_end_dates_validation(self):
     if self.startDate and self.endDate:
         if self.endDate < self.startDate:
             raise Invalid(
                 _("End date should not be earlier than start date."))
Example #13
0
class IMission(IBasic, IImageScaleTraversable):
    """
    Plone UN Mission
    """

    title = schema.TextLine(title=u'Mission',
                            description=u'Brief title of mission. eg. '
                            'Public Consultation for UN Workshop.')

    description = schema.Text(title=u'Mission Objective',
                              description=u'Briefly describe the objectives '
                              'of the mission.')

    dexteritytextindexer.searchable('mission_scope')
    mission_scope = schema.Choice(
        title=_(u'Mission Scope'),
        vocabulary='ploneun.missions.mission_scope',
    )

    dexteritytextindexer.searchable('mission_city')
    mission_city = schema.TextLine(title=_(u'City'), required=False)

    country = schema.Choice(
        title=_(u'Country'),
        description=_(u'If Mission Scope is International, please select '
                      'a country.'),
        vocabulary='ploneun.vocabulary.country',
        required=True,
        missing_value=None,
    )

    startDate = schema.Datetime(title=_(u'Start date'), )

    endDate = schema.Datetime(title=_(u'End date'), )

    dexteritytextindexer.searchable('mission_members')
    form.widget(mission_members=AutocompleteMultiFieldWidget)
    mission_members = schema.List(
        title=_(u'Mission Members'),
        description=_(
            u'List of Mission Members. Enter '
            'name to search, select and press Enter to add. Repeat to '
            'to add additional members.'),
        value_type=schema.Choice(vocabulary=u"plone.principalsource.Users", ),
        required=True,
    )

    dexteritytextindexer.searchable('text')
    form.widget(text="plone.app.z3cform.wysiwyg.WysiwygFieldWidget")
    text = schema.Text(title=_(u'Notes'), required=False)

    dexteritytextindexer.searchable('contactName')
    contactName = schema.TextLine(title=_(u'Contact Person'), required=False)

    dexteritytextindexer.searchable('contactEmail')
    contactEmail = schema.TextLine(title=_(u'Contact Person Email'),
                                   required=False)

    dexteritytextindexer.searchable('contactPhone')
    contactPhone = schema.TextLine(title=_(u'Contact Person Phone'),
                                   required=False)

    @invariant
    def start_end_dates_validation(self):
        if self.startDate and self.endDate:
            if self.endDate < self.startDate:
                raise Invalid(
                    _("End date should not be earlier than start date."))
 def title(self):
     return _('Mission Facility Navigation')
Example #15
0
class IMissionReport(form.Schema, IImageScaleTraversable):
    """
    UN Mission Report
    """

    title = schema.TextLine(title=u'Title', required=True)

    dexteritytextindexer.searchable('report_author')
    form.widget(report_author=AutocompleteMultiFieldWidget)
    report_author = schema.List(
        title=_(u'Author(s)'),
        description=_(
            u'List of Authors. Enter '
            'name to search, select and press Enter to add. Repeat to '
            'to add additional members with principal author first.'),
        value_type=schema.Choice(vocabulary=u"plone.principalsource.Users"),
        default=[],
        missing_value=(),
        required=True,
    )

    dexteritytextindexer.searchable('report_outcome')
    report_outcome = schema.TextLine(
        title=_(u'Country / Regional Programme Outcome'),
        description=_(u'Enter outcome code here eg. IDN 101'),
        required=False)

    dexteritytextindexer.searchable('report_outcome_text')
    form.widget(
        report_outcome_text="plone.app.z3cform.wysiwyg.WysiwygFieldWidget")
    report_outcome_text = schema.Text(
        title=_(u'Contribution to Outcome'),
        description=_(
            u'Please describe briefly how your mission has'
            'contributed to realizing the relevant country/regional outcome.'),
        required=False)

    dexteritytextindexer.searchable('achievements_summary')
    form.widget(
        achievements_summary="plone.app.z3cform.wysiwyg.WysiwygFieldWidget")
    achievements_summary = schema.Text(
        title=_(u'Achievements Summary'),
        description=_(u'Please fill this section in short telex style'),
        required=False)

    dexteritytextindexer.searchable('mission_findings')
    form.widget(
        mission_findings="plone.app.z3cform.wysiwyg.WysiwygFieldWidget")
    mission_findings = schema.Text(
        title=_(u'Mission Findings'),
        description=_(
            u'Please keep to approx 500 words. Other relevant documents'
            ' can be attached below.'),
        required=False)

    dexteritytextindexer.searchable('mission_followup')
    form.widget(
        mission_followup="plone.app.z3cform.wysiwyg.WysiwygFieldWidget")
    mission_followup = schema.Text(
        title=_(u'Follow-up actions/next steps'),
        description=_(u'In point form, include who should be doing what. '
                      u'One follow-up action per line.'),
        required=False)

    dexteritytextindexer.searchable('mission_contact')
    form.widget(mission_contact="plone.app.z3cform.wysiwyg.WysiwygFieldWidget")
    mission_contact = schema.Text(
        title=_(u'List of Contacts'),
        description=_(u'List of professionals and/or organizations met with '
                      u'during the mission'),
        required=False)

    dexteritytextindexer.searchable('mission_distribution')
    form.widget(mission_distribution=AutocompleteMultiFieldWidget)
    mission_distribution = schema.List(
        title=_(u'Distribution List (Members)'),
        description=_(u'Enter name to search, select and press Enter to add. '
                      'Repeat to add additional members'),
        value_type=schema.Choice(vocabulary='plone.principalsource.Users'),
        required=False)

    dexteritytextindexer.searchable('mission_distribution_others')
    mission_distribution_others = schema.List(
        title=_(u'Distribution List (Others)'),
        description=_(u'Enter additional email, one per line'),
        required=False,
        value_type=schema.TextLine())
 def title(self):
     return _('Mission Facility Navigation')