예제 #1
0
파일: controllers.py 프로젝트: jas01/indico
 def _process(self):
     self.user.settings.set('suggest_categories', True)
     tz = session.tzinfo
     hours, minutes = timedelta_split(tz.utcoffset(datetime.now()))[:2]
     categories = get_related_categories(self.user)
     categories_events = []
     if categories:
         category_ids = {c['categ'].id for c in categories.itervalues()}
         today = now_utc(False).astimezone(tz).date()
         query = (Event.query
                  .filter(~Event.is_deleted,
                          Event.category_chain_overlaps(category_ids),
                          Event.start_dt.astimezone(session.tzinfo) >= today)
                  .options(joinedload('category').load_only('id', 'title'),
                           joinedload('series'),
                           subqueryload('acl_entries'),
                           load_only('id', 'category_id', 'start_dt', 'end_dt', 'title', 'access_key',
                                     'protection_mode', 'series_id', 'series_pos', 'series_count'))
                  .order_by(Event.start_dt, Event.id))
         categories_events = get_n_matching(query, 10, lambda x: x.can_access(self.user))
     from_dt = now_utc(False) - relativedelta(weeks=1, hour=0, minute=0, second=0)
     linked_events = [(event, {'management': bool(roles & self.management_roles),
                               'reviewing': bool(roles & self.reviewer_roles),
                               'attendance': bool(roles & self.attendance_roles)})
                      for event, roles in get_linked_events(self.user, from_dt, 10).iteritems()]
     return WPUser.render_template('dashboard.html', 'dashboard',
                                   offset='{:+03d}:{:02d}'.format(hours, minutes), user=self.user,
                                   categories=categories,
                                   categories_events=categories_events,
                                   suggested_categories=get_suggested_categories(self.user),
                                   linked_events=linked_events)
    def _process(self, from_, include, limit):
        user = self._get_user()
        all_events = set()

        if 'linked' in include:
            all_events |= set(
                get_linked_events(user,
                                  from_,
                                  limit=limit,
                                  load_also=('description', 'own_room_id',
                                             'own_venue_id', 'own_room_name',
                                             'own_venue_name')))

        if 'categories' in include and (categories :=
                                        get_related_categories(user)):
            category_ids = {c['categ'].id for c in categories.values()}
            all_events |= set(
                get_events_in_categories(category_ids, user, limit=limit))
예제 #3
0
 def _process(self):
     self.user.settings.set('suggest_categories', True)
     categories = get_related_categories(self.user)
     categories_events = []
     if categories:
         category_ids = {c['categ'].id for c in categories.values()}
         categories_events = get_events_in_categories(category_ids, self.user)
     from_dt = now_utc(False) - relativedelta(weeks=1, hour=0, minute=0, second=0)
     linked_events = [(event, {'management': bool(roles & self.management_roles),
                               'reviewing': bool(roles & self.reviewer_roles),
                               'attendance': bool(roles & self.attendance_roles)})
                      for event, roles in get_linked_events(self.user, from_dt, 10).items()]
     return WPUserDashboard.render_template('dashboard.html', 'dashboard',
                                            user=self.user,
                                            categories=categories,
                                            categories_events=categories_events,
                                            suggested_categories=get_suggested_categories(self.user),
                                            linked_events=linked_events)
예제 #4
0
 def _process(self):
     self.user.settings.set('suggest_categories', True)
     tz = timezone(DisplayTZ().getDisplayTZ())
     hours, minutes = timedelta_split(tz.utcoffset(datetime.now()))[:2]
     categories = get_related_categories(self.user)
     categories_events = []
     if categories:
         category_ids = {c['categ'].id for c in categories.itervalues()}
         today = now_utc(False).astimezone(session.tzinfo).date()
         query = (Event.query.filter(
             ~Event.is_deleted, Event.category_chain_overlaps(category_ids),
             Event.start_dt.astimezone(session.tzinfo) >= today).options(
                 joinedload('category').load_only('id', 'title'),
                 joinedload('series'), subqueryload('acl_entries'),
                 load_only('id', 'category_id', 'start_dt', 'end_dt',
                           'title', 'access_key', 'protection_mode',
                           'series_id', 'series_pos',
                           'series_count')).order_by(
                               Event.start_dt, Event.id))
         categories_events = get_n_matching(
             query, 10, lambda x: x.can_access(self.user))
     from_dt = now_utc(False) - relativedelta(
         weeks=1, hour=0, minute=0, second=0)
     linked_events = [(event, {
         'management': bool(roles & self.management_roles),
         'reviewing': bool(roles & self.reviewer_roles),
         'attendance': bool(roles & self.attendance_roles)
     })
                      for event, roles in get_linked_events(
                          self.user, from_dt, 10).iteritems()]
     return WPUserDashboard.render_template(
         'dashboard.html',
         'dashboard',
         timezone=unicode(tz),
         offset='{:+03d}:{:02d}'.format(hours, minutes),
         user=self.user,
         categories=categories,
         categories_events=categories_events,
         suggested_categories=get_suggested_categories(self.user),
         linked_events=linked_events)
예제 #5
0
    def _process(self, from_, include, limit):
        categories = get_related_categories(self.user)
        categories_events = []
        if categories:
            category_ids = {c['categ'].id for c in categories.itervalues()}
            categories_events = get_events_in_categories(category_ids, self.user, limit=limit)

        linked_events = get_linked_events(
            self.user,
            from_,
            limit=limit,
            load_also=('description', 'own_room_id', 'own_venue_id', 'own_room_name', 'own_venue_name')
        )

        all_events = set()
        if 'linked' in include:
            all_events |= set(linked_events)
        if 'categories' in include:
            all_events |= set(categories_events)
        all_events = sorted(all_events, key=lambda e: (e.start_dt, e.id))[:limit]

        response = {'results': [serialize_event_for_ical(event, 'events') for event in all_events]}
        serializer = Serializer.create('ics')
        return send_file('event.ics', BytesIO(serializer(response)), 'text/calendar')