Example #1
0
    def delete(self, theme_id):
        theme = ThemeModel.find_by_id(theme_id)
        if theme:
            theme.delete_from_db()
            return {'message': 'Theme deleted'}

        return {'message': 'Theme not found'}
Example #2
0
    def put(self, theme_id):
        data = Theme.parser.parse_args()

        theme = ThemeModel.find_by_id(theme_id)

        if theme is None:  # Create a new theme if it does not exist in the database
            theme = ThemeModel(**data)
        else:  # Update the theme if it exists in the database
            theme.theme_name = data['theme_name']
            theme.theme_update = datetime.now()

        theme.save_to_db()

        return theme.json()
Example #3
0
 def get(self, theme_id):
     theme = ThemeModel.find_by_id(theme_id)
     if theme:
         return theme.json()
     return {'message': 'Theme not found'}, 404