示例#1
0
 def calendar_js_globals(self):
     limit_start = ISchedulingContext(self.context).start_date
     limit_end = ISchedulingContext(self.context).end_date
     cal_globals = dict(
         limit_start=limit_start.isoformat() if limit_start else None,
         limit_end=limit_end.isoformat() if limit_end else None,
         ical_url=self.ical_url,
         required_fields=[
             field.field.getName()
             for field in self.partial_event_form.form_fields
             if field.field.required
         ],
         view_url=self.url,
         venues_view_title=translate_i18n(TITLE_VENUES_VIEW),
         text_group=translate_i18n(FIELD_GROUP),
         text_start_date=translate_i18n(FIELD_START_DATE),
         text_end_date=translate_i18n(FIELD_END_DATE),
         text_venue=translate_i18n(FIELD_VENUE),
         text_activity_type=translate_i18n(_(u"Activity Type")),
         text_meeting_type=translate_i18n(_(u"Meeting Type")),
         text_convocation_type=translate_i18n(_(u"Convocation Type")),
         text_sitting=translate_i18n(TITLE_SITTING),
         text_view=translate_i18n(ACTION_VIEW_SITTING),
         error_messages=dict(
             default=_(u"Please check the highlighted sittings. "
                       "Failed to apply changes"),
             updated=_(u"Please review the highlighted sittings."
                       " Could not apply changes."),
             deleted=_(u"Please review the highlighted events."
                       " Could not be deleted.")))
     return """var cal_globals = %s;
         var timeline_data = { venues: %s, combined: %s };
         var group_urls= %s;""" % (
         json.dumps(cal_globals), json.dumps(self.venues_data),
         json.dumps(self.groups_data), json.dumps(self.calendar_urls()))
示例#2
0
    def process_form(self, data):
        class optionsobj(object):
            """Object that holds all the options."""

        self.options = optionsobj()
        if not hasattr(self, "short_name"):
            if "short_name" in data:
                self.short_name = data["short_name"]
        self.sittings = []
        if IGroupSitting.providedBy(self.context):
            trusted = removeSecurityProxy(self.context)
            order = "real_order" if self.display_minutes else "planned_order"
            trusted.item_schedule.sort(key=operator.attrgetter(order))
            self.sittings.append(trusted)
            self.start_date = self.context.start_date
            self.end_date = self.get_end_date(self.start_date,
                                              self.time_span(data))
        else:
            self.start_date = data["date"] if "date" in data else \
                                                datetime.datetime.today().date()
            self.end_date = self.get_end_date(self.start_date,
                                              self.time_span(data))
            sittings = ISchedulingContext(self.context).get_sittings(
                self.start_date, self.end_date).values()
            self.sittings = map(removeSecurityProxy, sittings)
        self.ids = ""
        for sitting in self.sittings:
            self.ids += str(sitting.group_sitting_id) + ","

        def cleanup(string):
            return string.lower().replace(" ", "_")

        for item_type in data["item_types"]:
            itemtype = cleanup(item_type)
            type_key = itemtype.rstrip("s").replace("_", "")
            setattr(self.options, type_key, True)
            setattr(self.options, itemtype, True)
            for option in data[itemtype + "_options"]:
                opt_key = "".join(
                    (cleanup(itemtype.rstrip("s")).replace("_", ""), "_",
                     cleanup(option)))
                setattr(self.options, opt_key, True)
        if self.display_minutes:
            self.link = url.absoluteURL(self.context, self.request) \
                                                + "/votes-and-proceedings"
        else:
            self.link = url.absoluteURL(self.context, self.request) + "/agenda"
        try:
            self.group = self.context.group
        except:
            self.group = ISchedulingContext(self.context).get_group()
示例#3
0
 def __init__(self, context, request, view, manager):
     while not ISchedulingContext.providedBy(context):
         context = ISchedulingContext(context, context.__parent__)
         if context is None:
             raise RuntimeError("Unable to locate a scheduling context.")
     super(SchedulablesViewlet, self).__init__(context, request, view,
                                               manager)
示例#4
0
def set_sitting_parent_ids(ob, event):
    """We add the group ID/sesssion id if adding a sitting in contexts
    not bound to groups in traversal hierarchy
    """
    scheduling_context = ISchedulingContext(ob.__parent__, None)
    if ob.group_id is None:
        if scheduling_context is not None:
            ob.group_id = removeSecurityProxy(scheduling_context).group_id
    if ob.session_id is None or IObjectModifiedEvent.providedBy(event):
        if scheduling_context is not None:
            group = scheduling_context.get_group()
            if interfaces.IChamber.providedBy(group):
                container = removeSecurityProxy(group).sessions
            else:
                return
        else:
            try:
                container = ob.group.sessions
            except AttributeError:
                return
        try:
            session_id = container._query.filter(
                sql.and_(
                    domain.Session.start_date < ob.start_date,
                    domain.Session.end_date > ob.end_date)).one().session_id
            ob.session_id = session_id
        except (orm.exc.NoResultFound, orm.exc.MultipleResultsFound):
            log.error("Could not determine session for sitting %s", ob)
示例#5
0
 def __call__(self, timestamp=None):
     trusted = removeSecurityProxy(self.context)
     trusted.__name__ = self.__name__
     interface.alsoProvides(trusted, ILocation)
     self.url = url.absoluteURL(trusted.__parent__, self.request)
     self.title = ISchedulingContext(self.context).label
     return self.render()
示例#6
0
    def handle_publish(self, action, data):
        self.generated_content = self.generateContent(data)
        if IWorkspaceScheduling.providedBy(self.request):
            if not hasattr(self.context, "group_id"):
                context_group_id = ISchedulingContext(self.context).group_id
            else:
                context_group_id = self.context.group_id
        else:
            #get the chamber id
            context_group_id = get_chamber_for_context(
                self.context).parliament_id
        report = domain.Report(
            title=self.title,
            start_date=self.start_date,
            end_date=self.end_date,
            body=self.generated_content,
            owner_id=get_login_user().user_id,  # !+GROUP_AS_OWNER
            language=self.language,
            group_id=context_group_id)
        session = Session()
        session.add(report)
        session.flush()
        notify(ObjectCreatedEvent(report))
        self.status = _(u"Report has been processed and saved")

        return self.template()
示例#7
0
 def __init__(self, context, request):
     super(DhtmlxCalendarSittings,
           self).__init__(ISchedulingContext(context), request)
     self.context.__name__ = self.__name__
     interface.alsoProvides(self.context, ILocation)
     interface.alsoProvides(self.context, IDCDescriptiveProperties)
     self.__parent__ = context
示例#8
0
    def validate(self, action, data):
        errors = super(ReportView, self).validate(action, data)
        time_span = self.time_span(data)
        if IGroupSitting.providedBy(self.context):
            if not self.context.items:
                errors.append(
                    interface.Invalid(
                        _(u"The sitting has no scheduled items")))
        else:
            start_date = data["date"] if "date" in data else \
                                                datetime.datetime.today().date()
            end_date = self.get_end_date(start_date, time_span)
            try:
                ctx = ISchedulingContext(self.context)
            except:
                errors.append(
                    interface.Invalid(
                        _(u"You are trying to generate a report "
                          "outside scheduling")))
            sittings = ctx.get_sittings(start_date, end_date).values()
            if not sittings:
                errors.append(
                    interface.Invalid(
                        _(u"The period selected has no sittings"), "date"))

            parliament = queries.get_parliament_by_date_range(
                start_date, end_date)
            if parliament is None:
                errors.append(
                    interface.Invalid(
                        _(u"A parliament must be active in the period"),
                        "date"))
        return errors
示例#9
0
 def handle_insert(self, action, data):
     session = Session()
     sitting = domain.GroupSitting()
     trusted = removeSecurityProxy(ISchedulingContext(self.context))
     group = session.query(domain.Group).get(trusted.group_id)
     if ("rec_type" not in data.keys()) or (data["rec_type"] == ""):
         sitting.start_date = datetime.datetime.strptime(data["start_date"], '%Y-%m-%d %H:%M')
         sitting.end_date = datetime.datetime.strptime(data["end_date"], '%Y-%m-%d %H:%M')
         sitting.group_id = trusted.group_id
         if "language" in data.keys():
             sitting.language = data["language"]
         if "venue" in data.keys():
             sitting.venue_id = data["venue"]
         session.add(sitting)
         notify(ObjectCreatedEvent(sitting))
         session.commit()
         self.request.response.setHeader('Content-type', 'text/xml')
         return '<data><action type="inserted" sid="'+str(data["ids"])+'" tid="'+str(sitting.sitting_id)+'" /></data>'
     else:
         try:
             recurrence_start_date = datetime.datetime.strptime(data["start_date"], '%Y-%m-%d %H:%M')
             recurrence_end_date = datetime.datetime.strptime(data["end_date"], '%Y-%m-%d %H:%M')
         except:
             print "Date is not in the correct format"
         year = timedelta(days=365)
         #max end date is one year from now or end_date of the group whichever is sooner
         if (group is not None) and (group.end_date is not None):
             if (datetime.datetime.now() + year) < group.end_date:
                 end = datetime.datetime.now() + year 
             else:
                 end = group.end_date
             if recurrence_end_date > end:
                 recurrence_end_date = end 
         else:
             if recurrence_end_date > (datetime.datetime.now() + year):
                 recurrence_end_date = datetime.datetime.now() + year
         recurrence_type = data["rec_type"]
         length = data["event_length"]
         sitting_length = timedelta(seconds=int(length))
         dates = self.generate_recurrence_dates(recurrence_start_date, recurrence_end_date, recurrence_type)
         output = '<data>'
         for date in dates:
             sitting = domain.GroupSitting()
             sitting.group_id = trusted.group_id
             sitting.start_date = date
             sitting.end_date = date + sitting_length
             sitting.status = None
             if "language" in data.keys():
                 sitting.language = data["language"]
             if "venue" in data.keys():
                 sitting.venue_id = data["venue"]
             session.add(sitting)
             notify(ObjectCreatedEvent(sitting))
             output = output+'<action type="inserted" sid="'+str(data["ids"])+'" tid="'+str(sitting.sitting_id)+'" />'
         session.commit()
         output = output + '</data>'
         self.request.response.setHeader('Content-type', 'text/xml')
         return output
示例#10
0
 def buildSittings(self):
     if ISitting.providedBy(self.context):
         trusted = removeSecurityProxy(self.context)
         order = "real_order"
         trusted.item_schedule.sort(key=operator.attrgetter(order))
         self.sittings.append(trusted)
     else:
         sittings = ISchedulingContext(self.context).get_sittings(
             self.start_date, self.end_date).values()
         self.sittings = map(removeSecurityProxy, sittings)
     self.sittings = [ExpandedSitting(sitting) for sitting in self.sittings]
示例#11
0
 def __init__(self, context, request):
     log.debug("CalendarView.__init__: %s" % (context))
     super(CalendarView, self).__init__(ISchedulingContext(context),
                                        request)
     self.context.__name__ = self.__name__
     self.context.title = self.short_name
     interface.alsoProvides(self.context, ILocation)
     interface.alsoProvides(self.context, IDCDescriptiveProperties)
     self.__parent__ = context
     log.debug(debug.interfaces(self))
     log.debug(debug.location_stack(self))
示例#12
0
def set_schedule_text_group(context, event):
    """Sets the current group id of schedule meta

    Headings and Notes
    """
    if hasattr(context, "group_id") and context.group_id is None:
        request_context = common.get_traversed_context()
        scheduling_context = ISchedulingContext(
            request_context.context.__parent__, None)
        if scheduling_context is not None:
            context.group_id = scheduling_context.group_id
示例#13
0
 def __call__(self, timestamp=None):
     trusted = removeSecurityProxy(self.context)
     trusted.__name__ = self.__name__
     interface.alsoProvides(trusted, ILocation)
     if (IBusinessSectionLayer.providedBy(self.request)
             and isinstance(trusted, SittingContainerSchedulingContext)):
         self.url = url.absoluteURL(trusted.__parent__.__parent__,
                                    self.request)
     else:
         self.url = url.absoluteURL(trusted.__parent__, self.request)
     self.title = ISchedulingContext(self.context).label
     return self.render()
示例#14
0
 def build_context(self):
     if ISitting.providedBy(self.context):
         sittings = [removeSecurityProxy(self.context)]
     else:
         sittings = map(
             removeSecurityProxy,
             ISchedulingContext(self.context).get_sittings(
                 self.start_date, self.end_date).values())
     # sort sittings chronologically
     sittings.sort(key=operator.attrgetter("start_date"))
     # ensure item_schedule is sorted via "real_order" within each sitting
     for sitting in sittings:
         sitting.item_schedule.sort(key=operator.attrgetter("real_order"))
     self.sittings = [ExpandedSitting(s) for s in sittings]
示例#15
0
 def __init__(self, context, request):
     log.debug("CalendarView.__init__: %s" % (context))
     super(CalendarView, self).__init__(ISchedulingContext(context),
                                        request)
     trusted = removeSecurityProxy(self.context)
     trusted.__name__ = self.__name__
     trusted.title = self.short_name
     interface.alsoProvides(trusted, ILocation)
     interface.alsoProvides(trusted, IDCDescriptiveProperties)
     if (IBusinessSectionLayer.providedBy(request)
             and isinstance(trusted, SittingContainerSchedulingContext)):
         self.url = url.absoluteURL(trusted.__parent__.__parent__, request)
     else:
         self.url = url.absoluteURL(trusted.__parent__, request)
     self.__parent__ = context
     log.debug(debug.interfaces(self))
     log.debug(debug.location_stack(self))
示例#16
0
 def generate_dates(self, data):
     trusted = removeSecurityProxy(ISchedulingContext(self.context))
     recurrence_start_date = data["start_date"].replace(tzinfo=None)
     recurrence_end_date = data["rec_end_date"].replace(tzinfo=None)
     group = trusted.get_group()
     # If group is none then there is a big problem
     assert group is not None
     year = timedelta(days=365)
     now = datetime.datetime.now()
     if (((group.end_date is not None) and ((now + year) < group.end_date))
             or (group.end_date is None)):
         end = now + year
     else:
         end = group.end_date
     if recurrence_end_date > end:
         recurrence_end_date = end
     return utils.generate_recurrence_dates(recurrence_start_date,
                                            recurrence_end_date,
                                            data["rec_type"])
示例#17
0
    def handle_publish(self, action, data):
        self.generated_content = self.generateContent(data)

        if not hasattr(self.context, "group_id"):
            context_group_id = ISchedulingContext(self.context).group_id
        else:
            context_group_id = self.context.group_id

        report = domain.Report(short_name=self.title,
                               start_date=self.start_date,
                               end_date=self.end_date,
                               body_text=self.generated_content,
                               owner_id=get_db_user_id(),
                               language=self.language,
                               group_id=context_group_id)
        session = Session()
        session.add(report)
        session.flush()
        self.status = _(u"Report has been processed and saved")

        return self.template()
示例#18
0
    def handle_save(self, action, data):
        report = domain.Report()
        session = Session()
        report.body = data["body"]
        report.start_date = data["start_date"]
        report.end_date = data["end_date"]
        report.note = data["note"]
        report.short_name = data["short_name"]
        report.owner_id = get_login_user().user_id  # !+GROUP_AS_OWNER
        report.language = get_default_language()
        report.created_date = datetime.datetime.now()
        if not hasattr(self.context, "group_id"):
            report.group_id = ISchedulingContext(self.context).group_id
        else:
            report.group_id = self.context.group_id
        session.add(report)
        session.flush()
        notify(ObjectCreatedEvent(report))
        if "sittings" in data.keys():
            try:
                ids = data["sittings"].split(",")
                for id_number in ids:
                    sit_id = int(id_number)
                    sitting = session.query(domain.Sitting).get(sit_id)
                    sr = domain.SittingReport()
                    sr.report = report
                    sr.sitting = sitting
                    session.add(sr)
                    notify(ObjectCreatedEvent(report))
            except:
                #if no sittings are present in report or some other error occurs
                pass
        session.flush()

        if ISitting.providedBy(self.context):
            back_link = "./schedule"
        else:
            back_link = "./"
        self.request.response.redirect(back_link)
示例#19
0
 def get_sittings_path(self):
     """get the url to the context sittings container"""
     scheduling_context = None
     context = self.context
     while scheduling_context is None:
         scheduling_context = ISchedulingContext(context, None)
         if not scheduling_context:
             context = context.__parent__
     if scheduling_context:
         try:
             ctx = scheduling_context.__parent__
             if hasattr(ctx, "sittings"):
                 sittings_container = ctx.sittings
             else:
                 sittings_container = removeSecurityProxy(ctx).publishTraverse(
                     self.request, "sittings"
                 )
             return url.absoluteURL(sittings_container, self.request)
         except NotFound:
             log.error("Could not determine sittings path for context %s",
                 self.context
             )
     return "../sittings"
示例#20
0
 def __init__(self, context, request):
     log.debug("CalendarView.__init__: %s" % (context))
     super(CalendarView, self).__init__(ISchedulingContext(context),
                                        request)
示例#21
0
    def handle_insert(self, action, data):
        session = Session()
        data["rec_end_date"] = data["end_date"]
        self.template_data = []
        trusted = removeSecurityProxy(ISchedulingContext(self.context))
        initial_sitting = None
        length = data["event_length"]
        venue_id = unicode(data["venue"]) if data['venue'] else None
        if data.get("rec_type") not in [None, "none"]:
            data["end_date"] = data["start_date"] + timedelta(seconds=length)
            self.request.form["end_date"] = data["end_date"].strftime(
                DT_FORMAT)
        data["headless"] = "true"
        self.request.form["venue_id"] = data["venue_id"] = venue_id
        self.request.form["headless"] = "true"
        add_form = AddForm(trusted.get_group().sittings, self.request)
        add_form.update()
        if not add_form.errors:
            initial_sitting = removeSecurityProxy(add_form.created_object)
        else:
            return self.insert_sitting_failure_handler(action, data,
                                                       add_form.errors)
        if ("rec_type" in data.keys()) and (data["rec_type"]
                                            not in [None, "none"]):
            # create recurring sittings
            #base_sitting_length = sitting_length + timedelta(hours=1)
            sitting_length = timedelta(seconds=length)
            base_sitting_length = timedelta(seconds=length) + timedelta(
                hours=1)
            dates = self.generate_dates(data)
            initial_sitting.recurring_type = data.get("rec_type")
            initial_sitting.recurring_id = 0
            initial_sitting.sitting_length = length
            for count, date in enumerate(dates):
                if not count:
                    #we've already added the initial sitting
                    initial_sitting.recurring_end_date = (
                        dates[len(dates) - 1] + base_sitting_length)
                    session.merge(initial_sitting)
                    continue

                sitting_data = copy(data)
                sitting_data["start_date"] = date.strftime(DT_FORMAT)
                sitting_data["end_date"] = (date +
                                            sitting_length).strftime(DT_FORMAT)

                request_copy = copy(self.request)
                request_copy.form = sitting_data
                add_form = AddForm(trusted.get_group().sittings, request_copy)
                add_form.update()
                if not add_form.errors:
                    # use finishConstruction API here
                    obj = add_form.created_object
                    obj.sitting_length = int(time.mktime(date.timetuple()))
                    obj.recurring_id = initial_sitting.sitting_id
                    session.merge(obj)
        else:
            initial_sitting.recurring_type = data.get("rec_type")
            initial_sitting.recurring_id = data.get("event_pid", 0)
            if data.get("event_length"):
                initial_sitting.sitting_length = data.get("event_length")
            session.merge(initial_sitting)
            wfc = IWorkflowController(initial_sitting)
            wfc.fireAutomatic()
        sitting_action = "inserted"
        if data["rec_type"] == "none":
            sitting_action = "deleted"
            session.merge(initial_sitting)
        self.template_data.append({
            "sitting_id": initial_sitting.sitting_id,
            "action": sitting_action,
            "ids": data["ids"],
        })
        self.request.response.setHeader("Content-type", "text/xml")
        return self.xml_template()
示例#22
0
 def __init__(self, context, request):
     super(CalendarView, self).__init__(ISchedulingContext(context),
                                        request)
示例#23
0
    def handle_insert(self, action, data):
        session = Session()
        self.template_data = []
        trusted = removeSecurityProxy(ISchedulingContext(self.context))
        if ("rec_type" in data.keys()) and (data["rec_type"] is not None):
            # !+ DATETIME(miano, dec-2010) the datetime widget above returns
            # aware datetime objects while the current database setup only
            # supports naive objects. The lines below(and in subsequent actions)
            # convert them to naive datetimes
            recurrence_start_date = data["start_date"].replace(tzinfo=None)
            recurrence_end_date = data["end_date"].replace(tzinfo=None)
            length = data["event_length"]
            sitting_length = timedelta(seconds=int(length))
            #
            # Check the end date of the recurrence
            # The end date is set to be the end date of the current group
            # or one year from the present date whichever is sooner.

            group = trusted.get_group()
            # If group is none then there is a big problem
            assert group is not None
            year = timedelta(days=365)
            now = datetime.datetime.now()
            if ((group.end_date is not None) and
                ((now + year) < group.end_date)) or (group.end_date is None):
                end = now + year
            else:
                end = group.end_date
            if recurrence_end_date > end:
                recurrence_end_date = end
            dates = utils.generate_recurrence_dates(recurrence_start_date,
                                                    recurrence_end_date,
                                                    data["rec_type"])
            recurrent_sittings = []
            for date in dates:
                sitting = domain.GroupSitting()
                sitting.group_id = trusted.group_id
                sitting.start_date = date
                sitting.end_date = date + sitting_length
                sitting.language = data["language"]
                sitting.venue_id = data["venue"]
                session.add(sitting)
                recurrent_sittings.append(sitting)
            session.flush()
            for s in recurrent_sittings:
                notify(ObjectCreatedEvent(s))
                self.template_data.append({
                    "group_sitting_id": s.group_sitting_id,
                    "action": "inserted",
                    "ids": data["ids"]
                })
            self.request.response.setHeader('Content-type', 'text/xml')
            return self.xml_template()
        else:
            sitting = domain.GroupSitting()
            sitting.start_date = data["start_date"].replace(tzinfo=None)
            sitting.end_date = data["end_date"].replace(tzinfo=None)
            sitting.group_id = trusted.group_id
            sitting.language = data["language"]
            sitting.venue_id = data["venue"]
            session.add(sitting)
            session.flush()
            notify(ObjectCreatedEvent(sitting))
            self.template_data.append({
                "group_sitting_id": sitting.group_sitting_id,
                "action": "inserted",
                "ids": data["ids"]
            })
            self.request.response.setHeader('Content-type', 'text/xml')
            return self.xml_template()
示例#24
0
 def handle_insert(self, action, data):
     self.template_data = []
     session = Session()
     trusted = removeSecurityProxy(ISchedulingContext(self.context))
     if ("rec_type" in data.keys()) and (data["rec_type"] is not None):
         try:
             recurrence_start_date = datetime.datetime \
                     .strptime(data["start_date"], '%Y-%m-%d %H:%M')
         except:
             log.error("The start date of the recurrence  \
                                 is not in the correct format")
         try:
             recurrence_end_date = datetime.datetime.strptime(
                                         data["end_date"], '%Y-%m-%d %H:%M')
         except:
             log.error("The start date of the recurrence is not in \
                                                     the correct format")   
         length = data["event_length"]
         sitting_length = timedelta(seconds=int(length))
         # Check the end date of the recurrence
         # The end date is set to be the end date of the current group 
         # or one year from the present date whichever is sooner.   
            
         group = trusted.get_group()
         # If group is none then there is a big problem
         assert group is not None    
         year = timedelta(days=365)
         now = datetime.datetime.now()                          
         if ((group.end_date is not None) and ((now + year) < group.end_date)) or (group.end_date is None):
             end = now + year 
         else:
             end = group.end_date
         if recurrence_end_date > end:
             recurrence_end_date = end 
         dates = utils.generate_recurrence_dates(recurrence_start_date, 
                                         recurrence_end_date, data["rec_type"])
         for date in dates:
             sitting = domain.GroupSitting()
             sitting.group_id = trusted.group_id
             sitting.start_date = date
             sitting.end_date = date + sitting_length
             sitting.status = None
             if "language" in data.keys():
                 sitting.language = data["language"]
             if "venue" in data.keys():
                 sitting.venue_id = data["venue"]
             # set extra data needed by template
             sitting.ids = data["ids"]
             sitting.action = 'inserted'
             session.add(sitting)
             # commiting after adding a sitting is incredibly inefficient
             # but thats the only way to get the sitting id.
             # Adding recurrring sittings is not a recurrent activity (see,
             # what I did there :)) so we can live with it.
             session.commit(sitting)
             notify(ObjectCreatedEvent(sitting))
             self.template_data.append({"sitting_id": sitting.sitting_id, 
                                        "action": "inserted",
                                        "ids": data["ids"]})
         self.request.response.setHeader('Content-type', 'text/xml')
         return self.template()
     else:
         sitting = domain.GroupSitting()
         try:
             sitting.start_date = datetime.datetime.strptime(
                                         data["start_date"], '%Y-%m-%d %H:%M')
         except:
             log.error("The start date of the sitting \
                                 is not in the correct format")
         try:
             sitting.end_date = datetime.datetime.strptime(data["end_date"], 
                                                             '%Y-%m-%d %H:%M')
         except:
             log.error("The end date of the sitting is not in the correct format")
             
         sitting.group_id = trusted.group_id
         if "language" in data.keys():
             sitting.language = data["language"]
         if "venue" in data.keys():
             sitting.venue_id = data["venue"]
         
         # set extra data needed by template
         sitting.ids = data["ids"]
         sitting.action = 'inserted'
         session.add(sitting)
         session.commit()
         notify(ObjectCreatedEvent(sitting))
         self.template_data.append({"sitting_id": sitting.sitting_id, 
                                    "action": "inserted",
                                    "ids": data["ids"]})
         
         self.request.response.setHeader('Content-type', 'text/xml')
         return self.template()