Exemplo n.º 1
0
 def post(self, server_type, server_id):
     """Create a new Album"""
     form = ns.payload
     server_group_id = get_group_id(server_type, server_id)
     if (Album.query.filter_by(server_group_id=server_group_id,
                               name=form["name"]).first() is not None):
         abort(400, f"Album {form['name']} already exists")
     album = Album(server_group_id=server_group_id, name=form["name"])
     db.session.add(album)
     db.session.commit()
     return album
Exemplo n.º 2
0
    def post(self, server_type, server_id):
        """Create a new Quote"""
        form = ns.payload
        server_group_id = get_group_id(server_type, server_id)

        quote = Quotes(
            server_group_id=server_group_id,
            quote_str=form["quote"],
            author=form["author"],
        )
        db.session.add(quote)
        db.session.commit()
        return quote
Exemplo n.º 3
0
    def post(self, server_type, server_id):
        """Create a new KeyWord"""
        form = ns.payload
        server_group_id = get_group_id(server_type, server_id)

        if (KeyWords.query.filter_by(server_group_id=server_group_id).filter(
                func.lower(KeyWords.name) == form["name"].lower()).first()
                is not None):
            abort(400, f"Key word {form['name']} already exists")
        keyWord = KeyWords(
            server_group_id=server_group_id,
            name=form["name"],
            responses=form["responses"],
        )
        db.session.add(keyWord)
        db.session.commit()
        return keyWord
Exemplo n.º 4
0
    def post(self, server_type, server_id):
        """Create a new Counter"""
        form = ns.payload
        server_group_id = get_group_id(server_type, server_id)

        if (Counter.query.filter_by(server_group_id=server_group_id).filter(
                func.lower(Counter.name) == form["name"].lower()).first()
                is not None):
            abort(400, f"Counter {form['name']} already exists")
        response = None
        if "response" in form:
            response = form["response"]
        if response is None:
            # response could still be None from the post data
            response = f"Counter {form['name']}" + " is now at {}"
        counter = Counter(
            server_group_id=server_group_id,
            name=form["name"],
            count=form.get("count", 0),
            response=response,
        )
        db.session.add(counter)
        db.session.commit()
        return counter