Esempio n. 1
0
def create_base_data():
    user = g.user
    data = {
        'user': user,
        'hostname': hostname,
        'current_time': timestamp(),
    }
    return data
Esempio n. 2
0
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))
Esempio n. 3
0
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
Esempio n. 4
0
	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})
Esempio n. 5
0
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)
Esempio n. 6
0
	def update_finish(self, filename, server):
		self.db.update({"status": Status.FINISHED, "endtime": timestamp()}, (where("filename") == filename) & (where("server") == server))
Esempio n. 7
0
	def update_error(self, filename, server):
		self.db.update({"status": Status.ERROR, "endtime": timestamp()}, (where("filename") == filename) & (where("server") == server))
Esempio n. 8
0
	def update_download(self, filename, server, user):
		self.db.update({"status": Status.DOWNLOADING, "starttime": timestamp(), "user": user}, (where("filename") == filename) & (where("server") == server))
Esempio n. 9
0
	def insertUrl(self, filename, url, size):
		return self.db.insert({"filename": filename, "server": url, "size": size, "known": False, "status": Status.QUEUE, "queuetime": timestamp()})
Esempio n. 10
0
	def insert(self, filename, server, size):
		return self.db.insert({"filename": filename, "server": server, "size": size, "known": True, "status": Status.QUEUE, "queuetime": timestamp()})
Esempio n. 11
0
	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)
Esempio n. 12
0
		def inc_usage(element):
			element["usage"] += usage
			element["timestamp"] = timestamp()
Esempio n. 13
0
def before_request():
    g.user = current_user
    if g.user.is_authenticated:
        g.user.last_seen = timestamp()
        g.user.save()