Example #1
0
 def events(self, req):
     user = req.authname
     event_id = req.args.get("obj_id") or None
     event = Event(self.env, event_id)
     cal_id = event_id and event.calendar or req.args.get("calendar")
     own = True
     if not event_id:
         event.calendar = cal_id
         event.allday = req.args.get("allDay") == "true" and 1 or 0
         ticket = req.args.get("ticket")
         ticket = ticket and Ticket(self.env, int(ticket)) or None
         if ticket and ticket.exists and "TICKET_VIEW" in req.perm(ticket.resource):
             event.ticket = ticket.id
             event.title = ticket["summary"]
             event.time_track = TimeTrack(self.env)
         getdate = lambda x: to_datetime(long(req.args[x]), utc)
         event.dtstart = getdate("date")
         event.dtend = event.dtstart + timedelta(minutes=60)
     else:
         cal = Calendar(self.env, event.calendar)
         own = cal.owner == user
         tt = TimeTrack(self.env, event.id, user)
         event.time_track = tt
     data = {
         "event": event and event_as_dict(event, own) or None,
         "tickets": TicketConfigRPC(self.env).my_active_tickets(req),
         "calendars": [
             cal_as_dict(cal, user)
             for cal in Calendar.select(self.env, owner=user)
             if cal.type != CalendarType.Reference
         ],
     }
     return "itteco_event_form.html", data, None
Example #2
0
 def query(self, req):
     """ Returns list of available Calendars. """
     username = req.authname
     out = []
     for c in Calendar.select(self.env):
         if 'CALENDAR_VIEW' in req.perm(c.resource):
             out.append(cal_as_dict(c, username))
     return out
Example #3
0
 def events(self, req):
     user = req.authname
     event_id = req.args.get('obj_id') or None
     event = Event(self.env, event_id)
     cal_id = event_id and event.calendar or req.args.get('calendar')
     own = True
     if not event_id:
         event.calendar = cal_id
         event.allday = req.args.get('allDay') == 'true' and 1 or 0
         ticket = req.args.get('ticket')
         ticket = ticket and Ticket(self.env, int(ticket)) or None
         if ticket and ticket.exists and 'TICKET_VIEW' in req.perm(
                 ticket.resource):
             event.ticket = ticket.id
             event.title = ticket['summary']
             event.time_track = TimeTrack(self.env)
         getdate = lambda x: to_datetime(long(req.args[x]), utc)
         event.dtstart = getdate('date')
         event.dtend = event.dtstart + timedelta(minutes=60)
     else:
         cal = Calendar(self.env, event.calendar)
         own = cal.owner == user
         tt = TimeTrack(self.env, event.id, user)
         event.time_track = tt
     data = {
         'event':
         event and event_as_dict(event, own) or None,
         'tickets':
         TicketConfigRPC(self.env).my_active_tickets(req),
         'calendars': [
             cal_as_dict(cal, user)
             for cal in Calendar.select(self.env, owner=user)
             if cal.type != CalendarType.Reference
         ]
     }
     return 'itteco_event_form.html', data, None
Example #4
0
def get_calendar_by_id(env, cal_id):
    cals= Calendar.select(env, id=cal_id)
    return cals and cals[0] or None
Example #5
0
def get_calendar_by_id(env, cal_id):
    cals = Calendar.select(env, id=cal_id)
    return cals and cals[0] or None