def deny_vocabulary_editor_permission(user_id, vocabulary_id) -> Dict[str, bool]: done = False msg = '' try: vocabulary = Vocabulary.query.filter_by( identifier=vocabulary_id).first() user = User.query.filter_by(id=user_id).first() if not vocabulary: msg = 'Vocabulary not found' elif not user: msg = 'User not found' else: db.session.add( ActionUsers.deny(ObjectVocabularyEditor(vocabulary.name), user=user)) db.session.commit() msg = 'Editor Permission granted over {0}'.format( vocabulary.name) done = True except Exception as e: # print(str(e)) msg = str(e) return msg, done
def deny_notification_viewed_permission(user_id, notification_id) -> Dict[str, bool]: done = False msg = '' try: notification = Notification.query.filter_by(id=notification_id).first() user = User.query.filter_by(id=user_id) if not notification: msg = 'Notification not found' elif not user: msg = 'User not found' else: db.session.add( ActionUsers.deny(ObjectNotificationEditor(notification.id), user=user) ) db.session.commit() msg = 'Mark as viewed Permission granted ' done = True except Exception as e: # print(str(e)) msg = str(e) return msg, done