示例#1
0
文件: events.py 项目: asenchi/drydrop
def log_event(action, code = 0, email = None, info = None):
    if email is None:
        user = users.get_current_user()
        if user is None:
            email = None
        else:
            email = user.email()
    
    event = Event(author=email, action = action, code = code, info = info)
    event.save()
示例#2
0
def log_event(action, code = 0, email = None, info = None):
    if email is None:
        user = users.get_current_user()
        if user is None:
            email = None
        else:
            email = user.email()
    domain = os.environ['SERVER_NAME']
    
    event = Event(author=email, action = action, code = code, info = info, domain=domain)
    event.save()
示例#3
0
def log_event(action, code=0, email=None, info=None):
    if email is None:
        user = users.get_current_user()
        if user is None:
            email = None
        else:
            email = user.email()
    domain = os.environ['SERVER_NAME']

    event = Event(author=email,
                  action=action,
                  code=code,
                  info=info,
                  domain=domain)
    event.save()
示例#4
0
 def events_flusher(self):
     domain = os.environ['SERVER_NAME']
     deleted = Event.clear(False, 1000, domain=domain)
     done = deleted<1000
     log_event("Removed all events")
     message = 'removed %d event(s)' % deleted
     if not done: message += ' ...'
     return self.render_json_response({
         'finished': done,
         'message': message
     })
示例#5
0
 def events_flusher(self):
     domain = os.environ['SERVER_NAME']
     deleted = Event.clear(False, 1000, domain=domain)
     done = deleted < 1000
     log_event("Removed all events")
     message = 'removed %d event(s)' % deleted
     if not done: message += ' ...'
     return self.render_json_response({
         'finished': done,
         'message': message
     })
示例#6
0
    def events(self):
        offset = int(self.params.get("offset", 0))
        limit = int(self.params.get("limit", 50))
        events = Event.all().filter(
            "domain =",
            os.environ['SERVER_NAME']).order('-date').fetch(limit, offset)
        res = []
        for e in events:
            res.append({
                "author": unicode(e.author),
                "action": unicode(e.action),
                "info": unicode(e.info),
                "code": e.code,
                "date": e.date
            })

        return self.render_json_response({'status': 0, 'data': res})
示例#7
0
 def events(self):
     offset = int(self.params.get("offset", 0))
     limit = int(self.params.get("limit", 50))
     events = Event.all().filter("domain =", os.environ['SERVER_NAME']).order('-date').fetch(limit, offset)
     res = []
     for e in events:
         res.append({
             "author": unicode(e.author),
             "action": unicode(e.action),
             "info": unicode(e.info),
             "code": e.code,
             "date": e.date
         })
     
     return self.render_json_response({
         'status': 0,
         'data': res
     })