Exemplo n.º 1
0
def reset_db():
    for user in User.all(): user.delete()

    for ycs in YearCourseSemester.all(): ycs.delete()

    for mod in Module.all(): mod.delete()

    for sub in Subscription.all(): sub.delete()

    for sub in Category.all(): sub.delete()

    for i in Thread.all(): i.delete()

    for i in Post.all(): i.delete()

    for i in Rating.all(): i.delete()

    for i in Assessment.all(): i.delete()

    for i in Grade.all(): i.delete()

    for i in Lecturer.all(): i.delete()

    for i in LecturerRating.all(): i.delete()
Exemplo n.º 2
0
def get_posts(tid):
    t = Thread.get_by_id(int(tid))
    #the bit below only fetches the 10 most recent posts 
    p = [p for p in t.posts.order('-answer').order('-timestamp').fetch(10)]
    return p