def _upgrade_to_teacher(email): from zeeguu.core.model import User, Teacher db = zeeguu.core.db u = User.find(email) db.session.add(Teacher(u)) db.session.commit()
def add_colleague_to_cohort(): cohort_id = request.form.get("cohort_id") colleague_email = request.form.get("colleague_email") check_permission_for_cohort(id) colleague = User.find(colleague_email) cohort = Cohort.find(cohort_id) db.session.add(TeacherCohortMap(colleague, cohort)) db.session.commit() return "OK"
def setUp(self, mock_invite_code): # idea from here: # https: // docs.pytest.org / en / latest / example / simple.html # detect-if-running-from-within-a-pytest-run # allows the api translate_and_Bookmark to know that it's being called from the unit test # and use the reverse translator instead of the real translators app.testing = True self.app = app.test_client() zeeguu.core.db.create_all() response = self.app.post(f"/add_user/{TEST_EMAIL}", data=test_user_data) self.session = str(int(response.data)) self.user = User.find(TEST_EMAIL)
from zeeguu.core.model import User import sys def forget_user(user): old_email = user.email old_name = user.name fake = Faker() user.name = "Forgotten Learner" user.email = fake.email() session = zeeguu.core.db.session session.add(user) session.commit() print( f"Before: {old_name} / {old_email} \nAfter: {user.name} / {user.email}" ) if __name__ == "__main__": if len(sys.argv) < 2: print(f"Usage: {sys.argv[0]} <email>") exit(-1) user = User.find(sys.argv[1]) forget_user(user)