Ejemplo n.º 1
0
def ui_edit_channel(identifier):
    # Get channel info
    channel = Controller.get_channel(identifier)
    form = ChannelForm(formdata=request.form, separator=channel['separator'],
                       artist_before_title=channel['artist_before_title'])

    if channel:
        if request.method == 'POST' and form.validate():
            # save edits
            class Args:
                separator = form.separator.data
                artist_before_title = form.artist_before_title.data

            Controller.update_channel(identifier, Args())
            return redirect('/ui/channels')
        return render_template('channels/edit_channel.html', form=form, channel=channel['channel'])
Ejemplo n.º 2
0
 def post(identifier):
     parser = reqparse.RequestParser()
     parser.add_argument('separator', required=True)
     parser.add_argument('artist_before_title', required=True)
     args = parser.parse_args()
     return {
         'message': 'Channel has been updated.',
         'data': Controller.update_channel(identifier, args)
     }, 201