def getDay(self, date): clean_date = '"' + date + '"' brains = self.portal_catalog.unrestrictedSearchResults( path=self.getPath(), portal_type='Day', Title=clean_date, ) if len(brains) == 0: raise ValueError(_('The date %s was not found.' % date)) return brains[0].getObject()
def cancelBooking(self): '''Processing that happens when a user is cancelling a given booking for a session.''' if self.request.form.get('form.submitted') == '1' and \ self.request.form.get('form.button.Submit') == \ 'Cancel selected session': self.authenticateForm() selectedSlots = self.request.get('selectedSlot', None) if type(selectedSlots) != list: selectedSlots = [selectedSlots] if selectedSlots != [None]: plone_utils = getToolByName(self.context, 'plone_utils') student_details = self.getStudentDetailsFromSdm() for slot in selectedSlots: try: booking_session = self.getBookingSessionByUid(slot) login_id = student_details['login_id'] person = booking_session[login_id] booking_session.manage_delObjects([login_id,]) try: #EMAIL: Send cancellation message to our user mail.sendNotificationEmail(context=self.context, person=person, email_type=config.EHS_CANCELLATION_EMAIL) notify(PersonCancelledEvent(person)) plone_utils.addPortalMessage(_(u'Your selected booking was cancelled successfully. You have been sent a confirmation email.'), 'info') except: raise plone_utils.addPortalMessage(_(u'Your selected booking was cancelled successfully but a confirmation email could not be sent.'), 'warning') self.has_cancelled = True except: raise plone_utils.addPortalMessage(_(u'Your booking could not be cancelled. Please contact Enrolment Help.'), 'error') view = ViewPageTemplateFile("show-bookings.pt") return view(self)
def getTimeSlot(self, title): clean_title = '"' + title + '"' brains = self.portal_catalog.unrestrictedSearchResults( portal_type='Time Slot', Title=clean_title, path=self.getPath(), depth=1, ) if len(brains) == 0: raise ValueError(_('The TimeSlot %s was not found.' % title)) timeSlot = brains[0].getObject() return timeSlot
from uwosh.timeslot import timeslotMessageFactory as _ from uwosh.timeslot.interfaces import ISignupSheet from uwosh.timeslot.config import PROJECTNAME from uwosh.timeslot.utilities import getAllExtraFields import csv from StringIO import StringIO from DateTime import DateTime SignupSheetSchema = folder.ATFolderSchema.copy() + atapi.Schema(( atapi.BooleanField( 'allowSignupForMultipleSlots', storage=atapi.AnnotationStorage(), widget=atapi.BooleanWidget( label=_(u'Allow Signup For Multiple Slots'), description=_( u'Allow the user to signup for more than one slot.'))), atapi.StringField( 'showSlotNames', storage=atapi.AnnotationStorage(), widget=atapi.BooleanWidget( label=_(u'Show Individual Time Slot Names'), description=_(u'Whether or not to show individual slot names.'))), atapi.LinesField( 'extraFields', storage=atapi.AnnotationStorage(), vocabulary="getExtraFieldsVocabulary", widget=atapi.MultiSelectionWidget( label=_(u'Extra Fields'), description=_(u'Information you want to collect from users besides'
from Products.Archetypes import atapi from Products.ATContentTypes.content import folder from Products.ATContentTypes.content import schemata from uwosh.timeslot import timeslotMessageFactory as _ from uwosh.timeslot.interfaces import IDay, ICloneable from uwosh.timeslot.config import PROJECTNAME DaySchema = folder.ATFolderSchema.copy() + atapi.Schema(( atapi.DateTimeField( 'date', storage=atapi.AnnotationStorage(), required=True, widget=atapi.CalendarWidget(label=_('Date'), show_hm=False) ), )) DaySchema['title'].required = False DaySchema['title'].widget.visible = { 'view': 'invisible', 'edit': 'invisible', } DaySchema['title'].storage = atapi.AnnotationStorage() DaySchema['description'].widget.visible = { 'view': 'invisible', 'edit': 'invisible', }
from Products.Archetypes import atapi from Products.ATContentTypes.content import base from Products.ATContentTypes.content import schemata from uwosh.timeslot import timeslotMessageFactory as _ from uwosh.timeslot.interfaces import IPerson from uwosh.timeslot.config import PROJECTNAME from Products.CMFCore.utils import getToolByName PersonSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema(( atapi.StringField('email', storage=atapi.AnnotationStorage(), widget=atapi.StringWidget( label=_(u'E-Mail'), description=_(u'Your email address')), validators=('isEmail')), atapi.StringField('phone', storage=atapi.AnnotationStorage(), widget=atapi.StringWidget( label=_(u'Phone'), description=_(u'Your phone number'))), atapi.StringField('department', storage=atapi.AnnotationStorage(), widget=atapi.StringWidget( label=_(u'Department'), description=_(u'Your department'))), atapi.StringField('classification', storage=atapi.AnnotationStorage(), widget=atapi.StringWidget(
from Products.Archetypes import atapi from Products.ATContentTypes.content import folder from Products.ATContentTypes.content import schemata from uwosh.timeslot import timeslotMessageFactory as _ from uwosh.timeslot.interfaces import ITimeSlot, ICloneable from uwosh.timeslot.config import PROJECTNAME from uwosh.timeslot.widget import TimeWidget from DateTime import DateTime TimeSlotSchema = folder.ATFolderSchema.copy() + atapi.Schema(( atapi.DateTimeField('startTime', storage=atapi.AnnotationStorage(), widget=TimeWidget(label=_('Start Time'), format='%I:%M %p') ), atapi.DateTimeField('endTime', storage=atapi.AnnotationStorage(), widget=TimeWidget(label=_('End Time'), show_ymd=False, format='%I:%M %p') ), atapi.StringField('name', storage=atapi.AnnotationStorage(), widget=atapi.StringWidget(label=_('Name'), description=_(u'Optional name')) ),
from zope.interface import implements from Products.Archetypes import atapi from Products.ATContentTypes.content import folder from Products.ATContentTypes.content import schemata from uwosh.timeslot import timeslotMessageFactory as _ from uwosh.timeslot.interfaces import ITimeSlot, ICloneable from uwosh.timeslot.config import PROJECTNAME from uwosh.timeslot.widget import TimeWidget TimeSlotSchema = folder.ATFolderSchema.copy() + atapi.Schema(( atapi.DateTimeField('startTime', storage=atapi.AnnotationStorage(), widget=TimeWidget(label=_('Start Time'))), atapi.DateTimeField('endTime', storage=atapi.AnnotationStorage(), widget=TimeWidget(label=_('End Time'))), atapi.StringField('name', storage=atapi.AnnotationStorage(), widget=atapi.StringWidget( label=_('Name'), description=_(u'Optional name'))), atapi.IntegerField('maxCapacity', storage=atapi.AnnotationStorage(), default=1, required=True, widget=atapi.IntegerWidget( label=_(u'Max Capacity'), description=_(u'The max number of people'))), atapi.BooleanField( 'allowWaitingList',
from Products.ATContentTypes.content import folder from Products.ATContentTypes.content import schemata from uwosh.timeslot import timeslotMessageFactory as _ from uwosh.timeslot.interfaces import ITimeSlot, ICloneable from uwosh.timeslot.config import PROJECTNAME from uwosh.timeslot.widget import TimeWidget TimeSlotSchema = folder.ATFolderSchema.copy() + atapi.Schema(( atapi.DateTimeField( 'startTime', storage=atapi.AnnotationStorage(), widget=TimeWidget( label=_('Start Time')) ), atapi.DateTimeField( 'endTime', storage=atapi.AnnotationStorage(), widget=TimeWidget( label=_('End Time')) ), atapi.StringField( 'name', storage=atapi.AnnotationStorage(), widget=atapi.StringWidget( label=_('Name'), description=_(u'Optional name'))
from uwosh.timeslot import timeslotMessageFactory as _ from uwosh.timeslot.interfaces import ISignupSheet from uwosh.timeslot.config import PROJECTNAME from uwosh.timeslot.utilities import getAllExtraFields import csv from StringIO import StringIO from DateTime import DateTime SignupSheetSchema = folder.ATFolderSchema.copy() + atapi.Schema(( atapi.BooleanField( 'allowSignupForMultipleSlots', storage=atapi.AnnotationStorage(), widget=atapi.BooleanWidget( label=_(u'Allow Signup For Multiple Slots'), description=_(u'Allow the user to signup for more than one slot.')) ), atapi.StringField( 'showSlotNames', storage=atapi.AnnotationStorage(), widget=atapi.BooleanWidget( label=_(u'Show Individual Time Slot Names'), description=_(u'Whether or not to show individual slot names.')) ), atapi.LinesField( 'extraFields', storage=atapi.AnnotationStorage(), vocabulary="getExtraFieldsVocabulary",
from uwosh.timeslot import timeslotMessageFactory as _ from uwosh.timeslot.interfaces import ITimeSlot, ICloneable from uwosh.timeslot import config from uwosh.timeslot.widget import TimeWidget from uwosh.timeslot import util from DateTime import DateTime from Acquisition import aq_parent TimeSlotSpecialSchema = atapi.Schema(( atapi.DateTimeField('startTime', storage=atapi.AnnotationStorage(), required=True, widget=TimeWidget(label=_(u'Start Time'), format='%I:%M %P') ), atapi.DateTimeField('endTime', storage=atapi.AnnotationStorage(), required=True, validators = ('isEndTimeAfterStartTime',), widget=TimeWidget(label=_(u'End Time'), show_ymd=False, format='%I:%M %P') ), atapi.StringField('name', storage=atapi.AnnotationStorage(), required=True,
from Products.ATContentTypes.content import folder from Products.ATContentTypes.content import schemata from Products.ATContentTypes.configuration import zconf from collective.easytemplate.fields import TemplatedTextField from uwosh.timeslot import timeslotMessageFactory as _ from uwosh.timeslot.interfaces import ISignupSheet from uwosh.timeslot import config, util from uwosh.timeslot.content.person import DummyExposedPersonSchema SignupSheetSchema = folder.ATFolderSchema.copy() + atapi.Schema(( atapi.BooleanField('allowSignupForMultipleSlots', storage=atapi.AnnotationStorage(), widget=atapi.BooleanWidget(label=_(u'Allow Signup For Multiple Slots'), description=_(u'Allow the user to signup for more than one slot.')) ), atapi.StringField('showSlotNames', storage=atapi.AnnotationStorage(), widget=atapi.BooleanWidget(label=_(u'Show Individual Time Slot Names'), description=_(u'Whether or not to show individual slot names.')) ), #This field exists for legacy reasons from original product. atapi.LinesField('extraFields', storage=atapi.AnnotationStorage(), vocabulary=[('phone','Phone'), ('department','Department'), ('classification','Employee Classification')], widget=atapi.MultiSelectionWidget(label=_(u'Extra Fields'), description=_(u'Information you want to collect from users besides just name and email.'),
from Products.ATContentTypes.content import base from Products.ATContentTypes.content import schemata from uwosh.timeslot import timeslotMessageFactory as _ from uwosh.timeslot.interfaces import IPerson from uwosh.timeslot.config import PROJECTNAME from Products.CMFCore.utils import getToolByName PersonSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema(( atapi.StringField( 'email', storage=atapi.AnnotationStorage(), widget=atapi.StringWidget( label=_(u'E-Mail'), description=_(u'Your email address')), validators=('isEmail') ), atapi.StringField( 'phone', storage=atapi.AnnotationStorage(), widget=atapi.StringWidget( label=_(u'Phone'), description=_(u'Your phone number')) ), atapi.StringField( 'department', storage=atapi.AnnotationStorage(),
from Products.ATContentTypes.content import schemata from uwosh.timeslot import timeslotMessageFactory as _ from uwosh.timeslot.interfaces import ISignupSheet from uwosh.timeslot.config import PROJECTNAME from uwosh.timeslot.utilities import getAllExtraFields import csv from StringIO import StringIO from DateTime import DateTime SignupSheetSchema = folder.ATFolderSchema.copy() + atapi.Schema(( atapi.BooleanField('allowSignupForMultipleSlots', storage=atapi.AnnotationStorage(), widget=atapi.BooleanWidget(label=_(u'Allow Signup For Multiple Slots'), description=_(u'Allow the user to signup for more than one slot.')) ), atapi.StringField('showSlotNames', storage=atapi.AnnotationStorage(), widget=atapi.BooleanWidget(label=_(u'Show Individual Time Slot Names'), description=_(u'Whether or not to show individual slot names.')) ), atapi.LinesField('extraFields', storage=atapi.AnnotationStorage(), vocabulary="getExtraFieldsVocabulary", widget=atapi.MultiSelectionWidget(label=_(u'Extra Fields'), description=_(u'Information you want to collect from users besides just name and email.'), format=_(u'checkbox'))
def __call__(self, *args, **kwargs): #Recall our user's course selection from their session. plone_utils = getToolByName(self.context, 'plone_utils') self.student_details = self.getStudentDetailsFromSdm() self.booked_session_uid = None member = self.getAuthenticatedMember() #If a user hasn't selected a course yet, then get them to. #Administrators are special -- they don't get bumped. if self.student_details is None and not self.showEditLinks() and not self.isBookingStaff(): self.request.response.redirect(self.context.absolute_url()+'/@@select-course') return #When submitting our form, do the following for validation/processing if self.request.form.get('form.submitted') == '1' and \ self.request.form.get('form.button.Submit') == 'Submit Form': self.authenticateForm() #Validate our fields from the page for field in ExposedPersonSchema.fields(): field_validation = field.validate(self.request.form.get(field.getName()), self.context) if field_validation: self.errors[field.getName()] = field_validation #Special case for personal email address if "confirmPersonalEmail" not in self.errors and self.request.form.get('pers_email') != self.request.form.get('confirmPersonalEmail'): self.errors['confirmPersonalEmail'] = "Confirmation email address does not match. Please check your input." #Special case for advanced standing if self.request.form.get('intendToApplyForAdvancedStanding') is '1' and self.request.form.get('submittedApplicationForAdvancedStanding') is None: self.errors['submittedApplicationForAdvancedStanding'] = "This field is required." #Special checks for our slotSelection; it's not a real field timeSlotUid = self.request.form.get('slotSelection') timeSlotUid = isinstance(timeSlotUid, basestring) and [timeSlotUid,] or timeSlotUid timeSlot = None if not timeSlotUid or len(timeSlotUid) != 1: self.errors['slotSelection'] = "Please select one enrolment session to book into." else: timeSlot = self.getBookingSessionByUid(timeSlotUid[0]) existing = timeSlot.get(self.student_details['login_id']) #XXX Need more checks here to make sure the student #can sign up for the given slot... if not timeSlot \ or timeSlot.isClosed() \ or timeSlot.isFull() \ or timeSlot.isInThePast() \ or timeSlot.getFaculty() != self.student_details['faculty_code'] \ or self.context.isUserSignedUpForAnySlot(self.student_details): self.errors['slotSelection'] = "Your could not be signed up for your selected session. It may have been cancelled, closed or become full. Please select a different session." elif existing: self.errors['slotSelection'] = "You are already attending this enrolment session for %s. Please choose another session." % existing.crs_full_nm #If we don't have any errors, we're good. Otherwise, we just fall through to displaying the form. if len(self.errors) == 0: try: #need to add/merge request details with student details here #They might have changed phone/email/etc and we need their #responses included. self.student_details.update(self.request.form) person = timeSlot.invokeFactory('Person', self.student_details['login_id'], **self.student_details) try: #EMAIL: Send confirmation email to our user mail.sendNotificationEmail(context=self.context, person=timeSlot[person], email_type=config.EHS_CONFIRMATION_EMAIL) plone_utils.addPortalMessage(_(u'Your booking was processed successfully. Your selected session is highlighted below.'), 'success') except: raise plone_utils.addPortalMessage(_(u'Your booking was processed successfully but a confirmation email could not be sent.'), 'warning') self.booked_session_uid = timeSlot.UID() except: raise self.errors['slotSelection'] = "Your could not be signed up for your selected session. The session may have been cancelled or become full. Please select a different session." #We're just loading the form, not submitting else: #Copy selected exposed schema attributes into the request.form #object to inject them onto the page. if self.student_details is not None: for field_key in ExposedPersonSchema.keys(): self.request.form.setdefault(field_key, self.student_details.get(field_key)) #Data reconfiguration before our page loads if self.student_details is not None: self.faculty_code = self.student_details['faculty_code'] self.faculty_name = config.FACULTY_LIST.getValue(self.faculty_code) else: self.faculty_code = '' self.faculty_name = "Administrative overview (all sessions)" #Inject our friendly error message if there's errors on the page if self.errors: plone_utils.addPortalMessage(_(u'Please correct the indicated errors before attempting to book a session.'), 'error') #print self.request.form return super(ChooseTimeSlot,self).__call__(args, kwargs)
from zope.interface import implements from Products.Archetypes import atapi from Products.ATContentTypes.content import folder from Products.ATContentTypes.content import schemata from uwosh.timeslot import timeslotMessageFactory as _ from uwosh.timeslot.interfaces import IDay, ICloneable from uwosh.timeslot.config import PROJECTNAME DaySchema = folder.ATFolderSchema.copy() + atapi.Schema(( atapi.DateTimeField('date', storage=atapi.AnnotationStorage(), required=True, widget=atapi.CalendarWidget(label=_('Date'), show_hm=False, format='%a, %b. %d, %Y', starting_year=2009) ), )) DaySchema['title'].required = False DaySchema['title'].widget.visible = {'view':'invisible', 'edit':'invisible'} DaySchema['title'].storage = atapi.AnnotationStorage() DaySchema['description'].widget.visible = {'view':'invisible', 'edit':'invisible'} DaySchema['description'].storage = atapi.AnnotationStorage() schemata.finalizeATCTSchema(DaySchema, folderish=True, moveDiscussion=False)
from Products.ATContentTypes.content import base from Products.ATContentTypes.content import schemata from uwosh.timeslot import timeslotMessageFactory as _ from uwosh.timeslot.interfaces import IPerson from uwosh.timeslot import config from Products.CMFCore.utils import getToolByName from Products.CMFCore.permissions import View ExposedPersonSchema = atapi.Schema(( atapi.StringField('home_ph', storage=atapi.AnnotationStorage(), required=True, widget=atapi.StringWidget(label=_(u'Daytime Contact Number'), description=_(u'Enter your daytime phone number.')), validators = ('saneIsPhoneNumber') ), atapi.StringField('mob_ph', storage=atapi.AnnotationStorage(), required=False, widget=atapi.StringWidget(label=_(u'Mobile Phone Number'), description=_(u'Enter your mobile phone number.')), validators = ('saneIsPhoneNumber') ), atapi.StringField('pers_email', storage=atapi.AnnotationStorage(), required=False,