def subscribe(user, module, a=0): Subscription(show_in_homepage=True, receive_notifications=True, subscribed_user=user, module=module).put() module.student_count+=1 module.put() for assessm in module.assessments: Grade(student=user,assessment=assessm).put() ratings=Rating.all().filter('module =', module).run() for rating in ratings: LecturerRating(lecturer=rating.lecturer,module=module,student=user).put()
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()
def associate(lecturer, module): rating = Rating(lecturer=lecturer,module=module) rating.teach_sum = 5 rating.overall_sum = 4 rating.teach_count = rating.overall_count = 1 rating.put()