Exemplo n.º 1
0
def demote_user(argv=sys.argv):
    if len(argv) < 2:
        print("Please enter a nickname!")
        sys.exit(1)

    username: str = argv[1]

    with transaction.manager:
        try:
            User.by_nickname(username).demote_to_user()
        except NoResultFound:
            print(
                f"The user `{username}` does not exist! Make sure you use the private and not the public nickname!"
            )
            sys.exit(1)
Exemplo n.º 2
0
    def test_user_to_issues(self):
        db_user: User = User.by_nickname("Björn")
        issue: Issue = DBDiscussionSession.query(Issue).get(8)

        self.assertNotIn(issue, db_user.participates_in)
        db_user.participates_in.append(issue)
        self.assertIn(issue, db_user.participates_in)

        association: UserParticipation = DBDiscussionSession.query(
            UserParticipation).filter_by(user_uid=db_user.uid,
                                         issue_uid=issue.uid).one_or_none()

        self.assertIsNotNone(association)

        DBDiscussionSession.query(UserParticipation).filter_by(
            user_uid=db_user.uid, issue_uid=issue.uid).delete()