(rname, rid)
This is a generic edit page for reactions
This is a generic edit page for reactions
This is a generic edit page for reactions
def editreact_page(rname, rid):
    ''' This is a generic edit page for reactions '''
    verify = verifyLogin(
        app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
    if verify:
        user = User()
        user.config = app.config
        user.get('uid', verify, g.rdb_conn)
        data = startData(user)
        data['active'] = 'dashboard'
        data['url'] = '/dashboard/edit-reactions/' + rname + '/' + rid
        tmpl = 'reactions/create.html'
        data['js_bottom'] = ['reactions/base.js', ]
        data['edit'] = True
        # Check Users Status
        if user.status != "active":
            data['url'] = '/dashboard/mod-subscription'
            tmpl = 'member/mod-subscription.html'
        else:
            reform = __import__(
                "reactionforms." + rname, globals(),
                locals(), ['ReactForm'], -1)
            form = reform.ReactForm(request.form)
            reaction = Reaction()
            reaction.config = app.config
            # If Edit get information
            reaction.get("rid", rid, g.rdb_conn)
            if reaction.uid == user.uid:
                data['reaction'] = {
                    'rid': reaction.rid,
                    'name': reaction.name,
                    'trigger': reaction.trigger,
                    'frequency': reaction.frequency,
                    'uid': reaction.uid,
                    'rtype': reaction.rtype,
                    'data': reaction.data
                }
            data['selects'] = []
            for item in form.__iter__():
                if item.type == "SelectField" or \
                        item.type == "SelectMultipleField":
                    item.default = data['reaction']['data'][item.name]
            tmpl = 'reactions/create.html'
            if request.method == 'POST':
                if form.validate():
                    reaction2 = Reaction()
                    reaction2.config = app.config
                    reaction2.rid = reaction.rid
                    reaction2.name = form.name.data
                    reaction2.trigger = form.trigger.data
                    reaction2.frequency = form.frequency.data
                    reaction2.lastrun = reaction.lastrun
                    reaction2.uid = user.uid
                    reaction2.rtype = reaction.rtype
                    tmpdata = {}
                    for item in form.__iter__():
                        tmpdata[item.name] = item.data
                        if item.type == "SelectField" or\
                                item.type == "SelectMultipleField":
                            item.default = item.data
                    reaction2.data = tmpdata

                    data['reaction'] = {
                        'rid': reaction2.rid,
                        'name': reaction2.name,
                        'trigger': reaction2.trigger,
                        'frequency': reaction2.frequency,
                        'uid': reaction2.uid,
                        'rtype': reaction2.rtype,
                        'data': reaction2.data
                    }
                    if reaction.uid == user.uid:
                        results = reaction2.editReaction(g.rdb_conn)
                    else:
                        results = False
                        print("/dashboard/reactions/{0} - \
                            Reaction edit failed: not owner".format(rname))
                        flash("It doesn't appear that you own this reaction.",
                              'danger')
                    if results == "exists":
                        print("/dashboard/reactions/{0} - \
                              Reaction edit failed: exists".format(rname))
                        flash('This reaction seems to already exist. \
                              Try using a different name.', 'danger')
                    elif results == "edit noexists":
                        print("/dashboard/reactions/{0} - \
                              Reaction edit failed: exists".format(rname))
                        flash('This reaction can not be edited \
                              as it does not exist.', 'danger')
                    elif results == "edit true":
                        print("/dashboard/reactions/{0} - \
                              Reaction edit successful".format(rname))
                        flash('Reaction successfully edited.', 'success')
                    elif results == "edit failed":
                        print("/dashboard/reactions/{0} - \
                              Reaction edit failed: unknown".format(rname))
                        flash('Reaction not successfully edited.', 'danger')
                    elif results is False:
                        print("/dashboard/reactions/{0} - \
                              Reaction edit failed: unknown".format(rname))
                        flash('Could not create reaction.', 'danger')
                    else:
                        stathat.ez_count(
                            app.config['STATHAT_EZ_KEY'],
                            app.config['ENVNAME'] + ' Reaction Added', 1)
                        print("/dashboard/reactions/{0} - \
                              Reaction edit success".format(rname))
                        flash('Reaction "{0}" successfully \
                              added.'.format(reaction2.name), 'danger')
                else:
                    print("/dashboard/reactions/{0} - \
                          Reaction edit failed: form invalid".format(rname))
                    flash('Form is not valid.', 'danger')
        form.process()
        page = render_template(tmpl, data=data, form=form)
        return page
    else:
        flash('Please Login.', 'warning')
        return redirect(url_for('user.login_page'))
def editreact_page ( rname , rid ) : verify = verifyLogin ( app . config [ 'SECRET_KEY' ] , app . config [ 'COOKIE_TIMEOUT' ] , request . cookies ) if verify : user = User ( ) user . config = app . config user . get ( 'uid' , verify , g . rdb_conn ) data = startData ( user ) data [ 'active' ] = 'dashboard' data [ 'url' ] = '/dashboard/edit-reactions/' + rname + '/' + rid tmpl = 'reactions/create.html' data [ 'js_bottom' ] = [ 'reactions/base.js' , ] data [ 'edit' ] = True # Check Users Status if user . status != "active" : data [ 'url' ] = '/dashboard/mod-subscription' tmpl = 'member/mod-subscription.html' else : reform = __import__ ( "reactionforms." + rname , globals ( ) , locals ( ) , [ 'ReactForm' ] , - 1 ) form = reform . ReactForm ( request . form ) reaction = Reaction ( ) reaction . config = app . config # If Edit get information reaction . get ( "rid" , rid , g . rdb_conn ) if reaction . uid == user . uid : data [ 'reaction' ] = { 'rid' : reaction . rid , 'name' : reaction . name , 'trigger' : reaction . trigger , 'frequency' : reaction . frequency , 'uid' : reaction . uid , 'rtype' : reaction . rtype , 'data' : reaction . data } data [ 'selects' ] = [ ] for item in form . __iter__ ( ) : if item . type == "SelectField" or item . type == "SelectMultipleField" : item . default = data [ 'reaction' ] [ 'data' ] [ item . name ] tmpl = 'reactions/create.html' if request . method == 'POST' : if form . validate ( ) : reaction2 = Reaction ( ) reaction2 . config = app . config reaction2 . rid = reaction . rid reaction2 . name = form . name . data reaction2 . trigger = form . trigger . data reaction2 . frequency = form . frequency . data reaction2 . lastrun = reaction . lastrun reaction2 . uid = user . uid reaction2 . rtype = reaction . rtype tmpdata = { } for item in form . __iter__ ( ) : tmpdata [ item . name ] = item . data if item . type == "SelectField" or item . type == "SelectMultipleField" : item . default = item . data reaction2 . data = tmpdata data [ 'reaction' ] = { 'rid' : reaction2 . rid , 'name' : reaction2 . name , 'trigger' : reaction2 . trigger , 'frequency' : reaction2 . frequency , 'uid' : reaction2 . uid , 'rtype' : reaction2 . rtype , 'data' : reaction2 . data } if reaction . uid == user . uid : results = reaction2 . editReaction ( g . rdb_conn ) else : results = False print ( "/dashboard/reactions/{0} - \
                            Reaction edit failed: not owner" . format ( rname ) ) flash ( "It doesn't appear that you own this reaction." , 'danger' ) if results == "exists" : print ( "/dashboard/reactions/{0} - \
                              Reaction edit failed: exists" . format ( rname ) ) flash ( 'This reaction seems to already exist. \
                              Try using a different name.' , 'danger' ) elif results == "edit noexists" : print ( "/dashboard/reactions/{0} - \
                              Reaction edit failed: exists" . format ( rname ) ) flash ( 'This reaction can not be edited \
                              as it does not exist.' , 'danger' ) elif results == "edit true" : print ( "/dashboard/reactions/{0} - \
                              Reaction edit successful" . format ( rname ) ) flash ( 'Reaction successfully edited.' , 'success' ) elif results == "edit failed" : print ( "/dashboard/reactions/{0} - \
                              Reaction edit failed: unknown" . format ( rname ) ) flash ( 'Reaction not successfully edited.' , 'danger' ) elif results is False : print ( "/dashboard/reactions/{0} - \
                              Reaction edit failed: unknown" . format ( rname ) ) flash ( 'Could not create reaction.' , 'danger' ) else : stathat . ez_count ( app . config [ 'STATHAT_EZ_KEY' ] , app . config [ 'ENVNAME' ] + ' Reaction Added' , 1 ) print ( "/dashboard/reactions/{0} - \
                              Reaction edit success" . format ( rname ) ) flash ( 'Reaction "{0}" successfully \
                              added.' . format ( reaction2 . name ) , 'danger' ) else : print ( "/dashboard/reactions/{0} - \
                          Reaction edit failed: form invalid" . format ( rname ) ) flash ( 'Form is not valid.' , 'danger' ) form . process ( ) page = render_template ( tmpl , data = data , form = form ) return page else : flash ( 'Please Login.' , 'warning' ) return redirect ( url_for ( 'user.login_page' ) )