Exemple #1
0
 def delete(self, **params):
     """Logic for deleting an artifact"""
     try:
         artifact = Artifact.find_by(id_=params["id"])
         artifact.delete()
         return no_content()
     except Artifact.DoesNotExist:
         return abort(404, "artifact not found")
    def post(self, **params):
        """Creates a new presentation with remotely requested images"""
        artifacts = []
        for artifact_id in params["file_ids"]:
            artifacts.append(Artifact.find_by(id_=artifact_id))

        socketio.emit("START_PRESENTATION", room=str(params["team_id"]), data=marshal_data(artifacts, ARTIFACTS_SCHEMA))
        return no_content()
Exemple #3
0
 def patch(self, **params):
     """Logic for updating an artifact"""
     try:
         artifact = Artifact.find_by(id_=params.pop("id"))
         builder = ArtifactConnector.for_artifact(artifact)
         builder.update_with(**params)
         return no_content()
     except Artifact.DoesNotExist:
         return abort(404, "artifact not found")
 def post(self, **params):
     """Logic for sending a password reset link"""
     user = User.find_by_email_or_username(params["email_or_username"])
     if not user:
         abort(404, "Could not find a user with that email address")
     token = password_reset_jwt_manager.encode_reset_token(user)
     reset_url = set_query_parameter(params["base_url"], "reset_token", token)
     send_reset_password_email(reset_url, user)
     return no_content()
Exemple #5
0
 def delete(self, **params):
     drive = Drive.find_by(id_=params["drive_id"])
     if drive.owner == User.find_by(id_=get_jwt_identity()):
         try:
             Drive.find_by(id_=params["drive_id"]).delete()
             return no_content()
         except Drive.NotFound:
             abort(404, "Drive not Found")
     else:
         abort(403)
Exemple #6
0
    def patch(self, **params):
        """Logic for updating multiple artifacts at once"""

        for update_data in params["artifacts"]:
            id = update_data.pop("id")
            try:
                artifact = Artifact.find_by(id_=id)
                builder = ArtifactConnector.for_artifact(artifact)
                builder.update_with(override_tags=False, **update_data)
            except Artifact.DoesNotExist:
                return abort(404, f"failed at <{id}>: not found")

        return no_content()
    def add_tags(self, **params):
        """Adds tags to an existing artifact"""
        try:
            artifact = Artifact.find_by(id_=params.pop("id"))
            builder = ArtifactConnector.for_artifact(artifact)
            existing_tags = artifact.tags or []

            new_list = existing_tags + list(
                set(params["tags"]) - set(existing_tags))

            builder.update_with(tags=new_list)
            return no_content()
        except Artifact.DoesNotExist:
            return abort(404, "artifact not found")
Exemple #8
0
 def delete(self, **params):
     """Logic for deleting a user"""
     user = User.find(params["id"])
     user.delete()
     return no_content()