示例#1
0
文件: app.py 项目: splitt/grabarz
 def get_schedule(self, year=None, month=None, day=None):
     """
     Pobiera z IWM liste powiadomień z danego miesiąca.
     """
     params = {}
     if year is not None:
         if month is not None:
             if day is not None:
                 params['from'] = '%d-%02d-%02dT00:00:00' % (year, month, day)
                 params['to'] = '%d-%02d-%02dT23:59:59' % (year, month, day)
             else:
                 params['from'] = '%d-%02d-01T00:00:00' % (year, month)
                 params['to'] = '%d-%02d-31T23:59:59' % (year, month)
         else:
             params['from'] = '%d-01-01T00:00:00' % year
             params['to'] = '%d-12-31T00:00:00' % year
     params['operator'] = get_loggedin_user_id()
     #params['author'] = get_loggedin_user_id()
     try:
         data = iwm_call(notification_list_inmapping, params,
                     notification_list_outmapping)
     except IWMResponseError:
         redirect_to('/calendar/app/handle_error')
     schedule = defaultdict(list)
     for note in data:
         date = note['date']
         schedule[(date.year, date.month,
                   date.day)].append(((date.hour, date.minute), note))
     return schedule
示例#2
0
文件: app.py 项目: splitt/grabarz
    def really_delete_note(self):
        """
        Actually delete the note and refresh calendar.
        """

        note_id = request.params['id']
        data = iwm_call(notification_delete_inmapping, {'id': note_id}, None)
        year, month, day = self.get_year_month_day()
        return [
            {
                'url': '/calendar/app/calendar_notes?year=%d&month=%d&day=%s' %
                    (year, month, day),
                'slot': 'calendar-notes',
            },
            {
                'url': '/calendar/app/calendar_listing?year=%d&month=%d' %
                    (year, month),
                'slot': 'calendar-content',
            },
        ]
示例#3
0
文件: app.py 项目: splitt/grabarz
    def get_notes_alert(self):
        """
        Displays alert with current notes.
        """
        # sekunda dodana na wypadek dluzszej obslugi requestu (ryzyko podwojnego wyswietlenia okna)
        delta = datetime.timedelta(seconds = 1 + int(config.get('notification_interval', 300)))
        unregister = {"type" : "timer-unregister", "result" : {"name": "notifications_alert"}}

        try:
            from_dt = session['alert_from_dt']
        except KeyError:
            from_dt = datetime.datetime.now() - delta

        to_dt = datetime.datetime.now()

        params = {}
        params['from'] = from_dt.isoformat()
        params['to'] = to_dt.isoformat()
        params['recipient-type'] = 'OPERATOR'
        params['operator'] = get_loggedin_user_id()

        try:
            data = iwm_call(notification_list_inmapping, params,
                        notification_list_outmapping)
        except:
            return [unregister,
                    {
                        'type': 'window',
                        'result': {
                            'heading': u'Wystąpił błąd aplikacji',
                            'html': u'<pre>Wystąpił błąd podczas próby pobrania przypomnień.\n'
                            u'Pobieranie przypomnień zostało wyłączone.</pre>',
                            'width': 480,
                            'height': 320,
                            'scrollable': True,
                            'slotname': 'common-error-window',
                            'replace': True
                            }
                        }
                    ]

        output = []
        you = get_loggedin_user_id()
        for note in data:
            date = note['date']
            operator = note['operator']

            if from_dt < date <= to_dt and operator == you:
                note_json = self._get_alert_window()
                note_json['slotname'] = note_json['slotname'] % (note['id'])
                note_json['object']['result']['content'] = '<p><b>%s</b></p><p>%s</p>' % (
                                       date.strftime('%Y-%m-%d %H:%M:%S'), note['text'])

                output.append(
                              {
                               'type' : 'window',
                               'result': note_json
                               }
                              )

        session['alert_from_dt'] = to_dt
        session.save()
        return output
示例#4
0
文件: app.py 项目: splitt/grabarz
    def really_add_note(self):
        """
        Do the actual addition of a note, and refresh the calendar.
        """

        params = dict(request.params)        
        date = datetime.datetime.strptime(' '.join([ params['date'], params['time'], ]), '%d-%m-%Y %H:%M')
        error_url = {
            'year': date.year,
            'month': date.month,
            'day': date.day,
            'time': params['time'],
            'text': params['text'],
            }
        if date.date() < datetime.date.today():
            error_url['date_error'] = 1
            return redirect('/calendar/app/add_note?%s' % urlencode(error_url))
        if date < datetime.datetime.now():
            error_url['time_error'] = 1
            return redirect('/calendar/app/add_note?%s' % urlencode(error_url))
        params['datetime'] = date
        operator = get_loggedin_user_data()
        params['author'] = operator['id']
        params['first-name'] = operator['first-name']
        params['last-name'] = operator['last-name']
        application = params.get('task-short-id', '')
        if application:
            summary_info = iwm_call(application_details_inmapping,
                                    {'task-short-id': application},
                                    application_details_get_outmapping)
            recipient = summary_info.get('operator-id', '')
            params['operator'] = recipient
        data = iwm_call(notification_add_inmapping, params, None)
        return [
            {
                'type': 'info',
                'result': {
                    'title': 'Przypomnienie',
                    'text': 'Dodano nowe przypomnienie',
                    'duration': 2500,
                },
            },
            {
                'type': 'reload',
                'result': {
                    'slot': 'calendar-content',
                    'silent': True,
                },
            },
            {
                'type': 'reload',
                'result': {
                    'slot': 'calendar-notes',
                    'silent': True,
                },
            },
            {
                'type': 'reload',
                'result': {
                    'slot': 'calendar-notes',
                    'silent': True,
                },
            },
            {
                'type': 'reload',
                'result': {
                    'slot': 'history-%s' % (application),
                    'silent': True,
                },
            },
        ]
示例#5
0
文件: app.py 项目: splitt/grabarz
 def get_note(self, note_id):
     data = iwm_call(notification_list_inmapping,
                     {'id': note_id},
                     notification_list_outmapping)
     return data[0]