[Python] CaveCMS

Status
Not open for further replies.
Got all fancy-dancy with the motto update box. Incorporated the first AJAX API, going to do more for other hotel functions. The waiting time in this animation is fabricated (wanted to show off the CSS3 spinner!), usually it will be much faster.

Bui - [Python] CaveCMS - RaGEZONE Forums


Code:
@cave.route('/api/update_motto', methods=['POST'])
def api_update_motto():
    if not g.user.is_authenticated():
        return abort(403)

    new_motto = request.form['new_motto']
    if not new_motto:
        return jsonify({'error': 'Please choose a new motto.'}), 400
    if len(new_motto) > cave.config['MAX_MOTTO_LENGTH']:
        return jsonify({'error': 'Your new motto is too long.'}), 400

    g.user.motto = new_motto
    db.session.commit()
    return jsonify({'message': 'Your motto was set successfully.'})

Code:
    $('#sb-motto-btn').click(function(){
        $('#sb-motto-btn').html('<div id="bowlG"><div id="bowl_ringG"><div class="ball_holderG"><div class="ballG">');
        $('#sb-motto-btn').attr('disabled', 'disabled');
        $('#me-mottobox').attr('disabled', 'disabled');
        $.post('api/update_motto', {'new_motto': $('#me-mottobox').val()})
            .done(function(data){
                $('#notif-area').prepend('<div class="alert alert-success"> \
                    <button type="button" class="close" data-dismiss="alert">×</button>' +  data['message'] + '</div>')
            })
            .fail(function(xhr, textStatus, errorThrown){
                $('#notif-area').prepend('<div class="alert alert-error"> \
                <button type="button" class="close" data-dismiss="alert">×</button>' +  JSON.parse(xhr.responseText)['error'] + '</div>')
            })
            .always(function(data){
                $('#sb-motto-btn').html('<i class="icon-pencil icon-white"></i>');
                $('#sb-motto-btn').removeAttr('disabled');
                $('#me-mottobox').removeAttr('disabled');}
    )});

Eventually, I'll have to write some JS helper functions. Not the best at JavaScript :P
 
Got all fancy-dancy with the motto update box. Incorporated the first AJAX API, going to do more for other hotel functions. The waiting time in this animation is fabricated (wanted to show off the CSS3 spinner!), usually it will be much faster.

Eventually, I'll have to write some JS helper functions. Not the best at JavaScript :P

Looks good :)
 
  • Like
Reactions: Bui
Got all fancy-dancy with the motto update box. Incorporated the first AJAX API, going to do more for other hotel functions. The waiting time in this animation is fabricated (wanted to show off the CSS3 spinner!), usually it will be much faster.

Bui - [Python] CaveCMS - RaGEZONE Forums


Code:
@cave.route('/api/update_motto', methods=['POST'])
def api_update_motto():
    if not g.user.is_authenticated():
        return abort(403)

    new_motto = request.form['new_motto']
    if not new_motto:
        return jsonify({'error': 'Please choose a new motto.'}), 400
    if len(new_motto) > cave.config['MAX_MOTTO_LENGTH']:
        return jsonify({'error': 'Your new motto is too long.'}), 400

    g.user.motto = new_motto
    db.session.commit()
    return jsonify({'message': 'Your motto was set successfully.'})

Code:
    $('#sb-motto-btn').click(function(){
        $('#sb-motto-btn').html('<div id="bowlG"><div id="bowl_ringG"><div class="ball_holderG"><div class="ballG">');
        $('#sb-motto-btn').attr('disabled', 'disabled');
        $('#me-mottobox').attr('disabled', 'disabled');
        $.post('api/update_motto', {'new_motto': $('#me-mottobox').val()})
            .done(function(data){
                $('#notif-area').prepend('<div class="alert alert-success"> \
                    <button type="button" class="close" data-dismiss="alert">×</button>' +  data['message'] + '</div>')
            })
            .fail(function(xhr, textStatus, errorThrown){
                $('#notif-area').prepend('<div class="alert alert-error"> \
                <button type="button" class="close" data-dismiss="alert">×</button>' +  JSON.parse(xhr.responseText)['error'] + '</div>')
            })
            .always(function(data){
                $('#sb-motto-btn').html('<i class="icon-pencil icon-white"></i>');
                $('#sb-motto-btn').removeAttr('disabled');
                $('#me-mottobox').removeAttr('disabled');}
    )});

Eventually, I'll have to write some JS helper functions. Not the best at JavaScript :P

For some reason I love that. Great job! ;P
 
  • Like
Reactions: Bui
For some reason I love that. Great job! ;P

Looking good, love the way of motto updating, good luck once again <3

Thanks :)

Did a similar thing when a tab on the left is clicked: a spinner and loading text (yes, the three dots come and go!) appear in the content area, and later I'll get them to make a request to the server to fetch whichever content the user asked for, then display it.

After I've done that, I'll do the register, and set up a test site!

Bui - [Python] CaveCMS - RaGEZONE Forums


Oh, and the /me page also constantly updates the user's visible stats ;)

Bui - [Python] CaveCMS - RaGEZONE Forums
 
This is pretty nice. However it's a pretty shame how you've took parts off Bootswatch.

Let's hope you won't take credit for it and good luck with further developing this very nice CMS!
 
He isn't taking credit for anything, I just provided a link incase anyone was interested.

Okay my bad I'm deeply sorry. Anyway thanks for it might do something with it.
 
I mentioned I'm using a Bootswatch theme in the OP. I'll properly attribute them at some point when I release this.

Anyway, finished the handling of content tabs via AJAX, just have to do the register now. Shouldn't take long once I start.
 
I personally like bootstrap. However, with the many projects and servers using bootstrap these days, I'd recommend using something such as to make it stand out. Good luck. :thumbup1:
 
Status
Not open for further replies.
Back