def create_base_data(): user = g.user data = { 'user': user, 'hostname': hostname, 'current_time': timestamp(), } return data
def add_point(lesson_id): form = request.form d = dict( name=form.get('name', ''), target=form.get('target', ''), content=form.get('content', ''), created_time=timestamp(), updated_time=timestamp(), ) point = Point(**d) point.save() lesson = Lesson.objects.get(id=lesson_id) print('debug', lesson.id) lesson.insert_point(point) # return redirect(url_for('.write_point', lesson_id=point.lesson_id)) return redirect(url_for('.write_point', lesson_id=lesson_id))
def create_base_data(): user = g.user nnr = g.notifies_not_read data = { 'user': user, 'hostname': hostname, 'current_time': timestamp(), 'not_read_count': nnr, } return data
def set_user(self, name, passwd, quota): user = self.db.get(where("name") == name) current = timestamp() if user: user["passwd"] = passwd; user["quota"] = quota midnight = datetime(current.year, current.month, current.day, 0, 0, 0) if user["timestamp"] < midnight: user["timestamp"] = current user["usage"] = 0 self.db.update(user, where("name") == name) else: self.db.insert({"name": name, "passwd": passwd, "quota": quota, "usage": 0, "timestamp": current})
def addpost(username, title, tags, text, about): user = find(username) post = Node('Post', id=(str(uuid.uuid4())) + username, title=title, text=text, about=about, timestamp=timestamp(), date=date()) rel = Relationship(user, 'PUBLISHED', post) graph.create(rel) tags = [x.strip() for x in tags.lower().split(',')] for name in set(tags): tag = Node('Tag', name=name) graph.merge( tag ) #MERGE command checks whether this node is available in the database or not. rel = Relationship(tag, 'TAGGED', post) graph.create(rel)
def update_finish(self, filename, server): self.db.update({"status": Status.FINISHED, "endtime": timestamp()}, (where("filename") == filename) & (where("server") == server))
def update_error(self, filename, server): self.db.update({"status": Status.ERROR, "endtime": timestamp()}, (where("filename") == filename) & (where("server") == server))
def update_download(self, filename, server, user): self.db.update({"status": Status.DOWNLOADING, "starttime": timestamp(), "user": user}, (where("filename") == filename) & (where("server") == server))
def insertUrl(self, filename, url, size): return self.db.insert({"filename": filename, "server": url, "size": size, "known": False, "status": Status.QUEUE, "queuetime": timestamp()})
def insert(self, filename, server, size): return self.db.insert({"filename": filename, "server": server, "size": size, "known": True, "status": Status.QUEUE, "queuetime": timestamp()})
def refresh_quotas(self): current = timestamp() midnight = datetime(current.year, current.month, current.day, 0, 0, 0) self.db.update({"usage": 0, "timestamp": current}, where("timestamp") < midnight)
def inc_usage(element): element["usage"] += usage element["timestamp"] = timestamp()
def before_request(): g.user = current_user if g.user.is_authenticated: g.user.last_seen = timestamp() g.user.save()