Beispiel #1
0
 def create_role(self, trans, **kwd):
     params = util.Params(kwd)
     message = util.restore_text(params.get('message', ''))
     status = params.get('status', 'done')
     name = util.restore_text(params.get('name', ''))
     description = util.restore_text(params.get('description', ''))
     in_users = util.listify(params.get('in_users', []))
     out_users = util.listify(params.get('out_users', []))
     in_groups = util.listify(params.get('in_groups', []))
     out_groups = util.listify(params.get('out_groups', []))
     create_group_for_role = params.get('create_group_for_role', '')
     create_group_for_role_checked = CheckboxField.is_checked(create_group_for_role)
     ok = True
     if params.get('create_role_button', False):
         if not name or not description:
             message = "Enter a valid name and a description."
             status = 'error'
             ok = False
         elif trans.sa_session.query(trans.app.model.Role).filter(trans.app.model.Role.table.c.name == name).first():
             message = "Role names must be unique and a role with that name already exists, so choose another name."
             status = 'error'
             ok = False
         else:
             # Create the role
             role, num_in_groups = trans.app.security_agent.create_role(
                 name, description, in_users, in_groups, create_group_for_role=create_group_for_role_checked)
             message = "Role '%s' has been created with %d associated users and %d associated groups.  " \
                 % (role.name, len(in_users), num_in_groups)
             if create_group_for_role_checked:
                 message += 'One of the groups associated with this role is the newly created group with the same name.'
             trans.response.send_redirect(web.url_for(controller='admin',
                                                      action='roles',
                                                      message=util.sanitize_text(message),
                                                      status='done'))
     if ok:
         for user in trans.sa_session.query(trans.app.model.User) \
                                     .filter(trans.app.model.User.table.c.deleted == false()) \
                                     .order_by(trans.app.model.User.table.c.email):
             out_users.append((user.id, user.email))
         for group in trans.sa_session.query(trans.app.model.Group) \
                                      .filter(trans.app.model.Group.table.c.deleted == false()) \
                                      .order_by(trans.app.model.Group.table.c.name):
             out_groups.append((group.id, group.name))
     return trans.fill_template('/webapps/tool_shed/admin/dataset_security/role/role_create.mako',
                                name=name,
                                description=description,
                                in_users=in_users,
                                out_users=out_users,
                                in_groups=in_groups,
                                out_groups=out_groups,
                                create_group_for_role_checked=create_group_for_role_checked,
                                message=message,
                                status=status)
Beispiel #2
0
 def edit_review( self, trans, **kwd ):
     # The value of the received id is the encoded review id.
     message = escape( kwd.get( 'message', '' ) )
     status = kwd.get( 'status', 'done' )
     review_id = kwd.get( 'id', None )
     review = review_util.get_review( trans.app, review_id )
     components_dict = odict()
     for component in review_util.get_components( trans.app ):
         components_dict[ component.name ] = dict( component=component, component_review=None )
     repository = review.repository
     repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False )
     for component_review in review.component_reviews:
         if component_review and component_review.component:
             component_name = component_review.component.name
             if component_name in components_dict:
                 component_review_dict = components_dict[ component_name ]
                 component_review_dict[ 'component_review' ] = component_review
                 components_dict[ component_name ] = component_review_dict
     # Handle a Save button click.
     save_button_clicked = False
     save_buttons = [ '%s%sreview_button' % ( comp_name, STRSEP ) for comp_name in components_dict.keys() ]
     save_buttons.append( 'revision_approved_button' )
     for save_button in save_buttons:
         if save_button in kwd:
             save_button_clicked = True
             break
     if save_button_clicked:
         # Handle the revision_approved_select_field value.
         revision_approved = kwd.get( 'revision_approved', None )
         revision_approved_setting_changed = False
         if revision_approved:
             revision_approved = str( revision_approved )
             if review.approved != revision_approved:
                 revision_approved_setting_changed = True
                 review.approved = revision_approved
                 trans.sa_session.add( review )
                 trans.sa_session.flush()
         saved_component_names = []
         for component_name in components_dict.keys():
             flushed = False
             # Retrieve the review information from the form.
             # The star rating form field is a radio button list, so it will not be received if it was not clicked in the form.
             # Due to this behavior, default the value to 0.
             rating = 0
             for k, v in kwd.items():
                 if k.startswith( '%s%s' % ( component_name, STRSEP ) ):
                     component_review_attr = k.replace( '%s%s' % ( component_name, STRSEP ), '' )
                     if component_review_attr == 'component_id':
                         component_id = str( v )
                     elif component_review_attr == 'comment':
                         comment = str( v )
                     elif component_review_attr == 'private':
                         private = CheckboxField.is_checked( v )
                     elif component_review_attr == 'approved':
                         approved = str( v )
                     elif component_review_attr == 'rating':
                         rating = int( str( v ) )
             component = review_util.get_component( trans.app, component_id )
             component_review = \
                 review_util.get_component_review_by_repository_review_id_component_id( trans.app,
                                                                                        review_id,
                                                                                        component_id )
             if component_review:
                 # See if the existing component review should be updated.
                 if component_review.comment != comment or \
                         component_review.private != private or \
                         component_review.approved != approved or \
                         component_review.rating != rating:
                     component_review.comment = comment
                     component_review.private = private
                     component_review.approved = approved
                     component_review.rating = rating
                     trans.sa_session.add( component_review )
                     trans.sa_session.flush()
                     flushed = True
                     saved_component_names.append( component_name )
             else:
                 # See if a new component_review should be created.
                 if comment or private or approved != trans.model.ComponentReview.approved_states.NO or rating:
                     component_review = trans.model.ComponentReview( repository_review_id=review.id,
                                                                     component_id=component.id,
                                                                     comment=comment,
                                                                     approved=approved,
                                                                     rating=rating )
                     trans.sa_session.add( component_review )
                     trans.sa_session.flush()
                     flushed = True
                     saved_component_names.append( component_name )
             if flushed:
                 # Update the repository rating value to be the average of all component review ratings.
                 average_rating = trans.sa_session.query( func.avg( trans.model.ComponentReview.table.c.rating ) ) \
                                                  .filter( and_( trans.model.ComponentReview.table.c.repository_review_id == review.id,
                                                                 trans.model.ComponentReview.table.c.deleted == false(),
                                                                 trans.model.ComponentReview.table.c.approved != trans.model.ComponentReview.approved_states.NA ) ) \
                                                  .scalar()
                 if average_rating is not None:
                     review.rating = int( average_rating )
                 trans.sa_session.add( review )
                 trans.sa_session.flush()
                 # Update the information in components_dict.
                 if component_name in components_dict:
                     component_review_dict = components_dict[ component_name ]
                     component_review_dict[ 'component_review' ] = component_review
                     components_dict[ component_name ] = component_review_dict
         if revision_approved_setting_changed:
             message += 'Approved value <b>%s</b> saved for this revision.<br/>' % review.approved
         if saved_component_names:
             message += 'Reviews were saved for components: %s' % ', '.join( saved_component_names )
         if not revision_approved_setting_changed and not saved_component_names:
             message += 'No changes were made to this review, so nothing was saved.'
     if review and review.approved:
         selected_value = review.approved
     else:
         selected_value = trans.model.ComponentReview.approved_states.NO
     revision_approved_select_field = grids_util.build_approved_select_field( trans,
                                                                              name='revision_approved',
                                                                              selected_value=selected_value,
                                                                              for_component=False )
     rev, changeset_revision_label = hg_util.get_rev_label_from_changeset_revision( repo, review.changeset_revision )
     return trans.fill_template( '/webapps/tool_shed/repository_review/edit_review.mako',
                                 repository=repository,
                                 review=review,
                                 changeset_revision_label=changeset_revision_label,
                                 revision_approved_select_field=revision_approved_select_field,
                                 components_dict=components_dict,
                                 message=message,
                                 status=status )
def render_render_registration_form(context, form_action=None):
    context.caller_stack._push_frame()
    try:
        _import_ns = {}
        _mako_get_namespace(context, '__anon_0x5b10f90')._populate(
            _import_ns, [u'render_msg'])
        redirect = _import_ns.get('redirect',
                                  context.get('redirect', UNDEFINED))
        username = _import_ns.get('username',
                                  context.get('username', UNDEFINED))
        trans = _import_ns.get('trans', context.get('trans', UNDEFINED))
        user_type_form_definition = _import_ns.get(
            'user_type_form_definition',
            context.get('user_type_form_definition', UNDEFINED))
        confirm = _import_ns.get('confirm', context.get('confirm', UNDEFINED))
        h = _import_ns.get('h', context.get('h', UNDEFINED))
        len = _import_ns.get('len', context.get('len', UNDEFINED))
        user_type_fd_id_select_field = _import_ns.get(
            'user_type_fd_id_select_field',
            context.get('user_type_fd_id_select_field', UNDEFINED))
        widgets = _import_ns.get('widgets', context.get('widgets', UNDEFINED))
        subscribe_checked = _import_ns.get(
            'subscribe_checked', context.get('subscribe_checked', UNDEFINED))
        cntrller = _import_ns.get('cntrller',
                                  context.get('cntrller', UNDEFINED))
        webapp = _import_ns.get('webapp', context.get('webapp', UNDEFINED))
        password = _import_ns.get('password',
                                  context.get('password', UNDEFINED))
        email = _import_ns.get('email', context.get('email', UNDEFINED))
        __M_writer = context.writer()
        # SOURCE LINE 24
        __M_writer(u'\n\n    ')
        # SOURCE LINE 26

        if form_action is None:
            form_action = h.url_for(controller='user',
                                    action='create',
                                    cntrller=cntrller)
        from galaxy.web.form_builder import CheckboxField
        subscribe_check_box = CheckboxField('subscribe')

        # SOURCE LINE 31
        __M_writer(
            u'\n\n    <div class="toolForm">\n        <form name="registration" id="registration" action="'
        )
        # SOURCE LINE 34
        __M_writer(unicode(form_action))
        __M_writer(
            u'" method="post" >\n            <div class="toolFormTitle">Create account</div>\n            <div class="form-row">\n                <label>Email address:</label>\n                <input type="text" name="email" value="'
        )
        # SOURCE LINE 38
        __M_writer(unicode(email))
        __M_writer(
            u'" size="40"/>\n                <input type="hidden" name="webapp" value="'
        )
        # SOURCE LINE 39
        __M_writer(unicode(webapp))
        __M_writer(
            u'" size="40"/>\n                <input type="hidden" name="redirect" value="'
        )
        # SOURCE LINE 40
        __M_writer(unicode(redirect))
        __M_writer(
            u'" size="40"/>\n            </div>\n            <div class="form-row">\n                <label>Password:</label>\n                <input type="password" name="password" value="'
        )
        # SOURCE LINE 44
        __M_writer(unicode(password))
        __M_writer(
            u'" size="40"/>\n            </div>\n            <div class="form-row">\n                <label>Confirm password:</label>\n                <input type="password" name="confirm" value="'
        )
        # SOURCE LINE 48
        __M_writer(unicode(confirm))
        __M_writer(
            u'" size="40"/>\n            </div>\n            <div class="form-row">\n                <label>Public name:</label>\n                <input type="text" name="username" size="40" value="'
        )
        # SOURCE LINE 52
        __M_writer(unicode(username))
        __M_writer(u'"/>\n')
        # SOURCE LINE 53
        if webapp == 'galaxy':
            # SOURCE LINE 54
            __M_writer(
                u'                    <div class="toolParamHelp" style="clear: both;">\n                        Your public name is an identifier that will be used to generate addresses for information\n                        you share publicly. Public names must be at least four characters in length and contain only lower-case\n                        letters, numbers, and the \'-\' character.\n                    </div>\n'
            )
            # SOURCE LINE 59
        else:
            # SOURCE LINE 60
            __M_writer(
                u'                    <div class="toolParamHelp" style="clear: both;">\n                        Your public name provides a means of identifying you publicly within this tool shed. Public\n                        names must be at least four characters in length and contain only lower-case letters, numbers,\n                        and the \'-\' character.  You cannot change your public name after you have created a repository\n                        in this tool shed.\n                    </div>\n'
            )
            pass
        # SOURCE LINE 67
        __M_writer(u'            </div>\n')
        # SOURCE LINE 68
        if trans.app.config.smtp_server:
            # SOURCE LINE 69
            __M_writer(
                u'                <div class="form-row">\n                    <label>Subscribe to mailing list:</label>\n'
            )
            # SOURCE LINE 71
            if subscribe_checked:
                # SOURCE LINE 72
                __M_writer(u'                        ')
                subscribe_check_box.checked = True

                __M_writer(u'\n')
                pass
            # SOURCE LINE 74
            __M_writer(u'                    ')
            __M_writer(unicode(subscribe_check_box.get_html()))
            __M_writer(
                u'\n                    <p>See <a href="http://galaxyproject.org/wiki/Mailing%20Lists" target="_blank">\n                    all Galaxy project mailing lists</a>.</p>\n                </div>\n'
            )
            pass
        # SOURCE LINE 79
        if user_type_fd_id_select_field and len(
                user_type_fd_id_select_field.options) > 1:
            # SOURCE LINE 80
            __M_writer(
                u'                <div class="form-row">\n                    <label>User type</label>\n                    '
            )
            # SOURCE LINE 82
            __M_writer(unicode(user_type_fd_id_select_field.get_html()))
            __M_writer(u'\n                </div>\n')
            pass
        # SOURCE LINE 85
        if user_type_form_definition:
            # SOURCE LINE 86
            for field in widgets:
                # SOURCE LINE 87
                __M_writer(
                    u'                    <div class="form-row">\n                        <label>'
                )
                # SOURCE LINE 88
                __M_writer(unicode(field['label']))
                __M_writer(u'</label>\n                        ')
                # SOURCE LINE 89
                __M_writer(unicode(field['widget'].get_html()))
                __M_writer(
                    u'\n                        <div class="toolParamHelp" style="clear: both;">\n                            '
                )
                # SOURCE LINE 91
                __M_writer(unicode(field['helptext']))
                __M_writer(
                    u'\n                        </div>\n                        <div style="clear: both"></div>\n                    </div>\n'
                )
                pass
            # SOURCE LINE 96
            if not user_type_fd_id_select_field:
                # SOURCE LINE 97
                __M_writer(
                    u'                    <input type="hidden" name="user_type_fd_id" value="'
                )
                __M_writer(
                    unicode(
                        trans.security.encode_id(
                            user_type_form_definition.id)))
                __M_writer(u'"/>\n')
                pass
            pass
        # SOURCE LINE 100
        __M_writer(
            u'            <div class="form-row">\n                <input type="submit" name="create_user_button" value="Submit"/>\n            </div>\n        </form>\n    </div>\n\n'
        )
        return ''
    finally:
        context.caller_stack._pop_frame()
Beispiel #4
0
def render_render_registration_form(context,form_action=None):
    context.caller_stack._push_frame()
    try:
        _import_ns = {}
        _mako_get_namespace(context, '__anon_0x7f71681b4710')._populate(_import_ns, [u'render_msg'])
        username = _import_ns.get('username', context.get('username', UNDEFINED))
        redirect = _import_ns.get('redirect', context.get('redirect', UNDEFINED))
        user_type_form_definition = _import_ns.get('user_type_form_definition', context.get('user_type_form_definition', UNDEFINED))
        h = _import_ns.get('h', context.get('h', UNDEFINED))
        len = _import_ns.get('len', context.get('len', UNDEFINED))
        user_type_fd_id_select_field = _import_ns.get('user_type_fd_id_select_field', context.get('user_type_fd_id_select_field', UNDEFINED))
        widgets = _import_ns.get('widgets', context.get('widgets', UNDEFINED))
        subscribe_checked = _import_ns.get('subscribe_checked', context.get('subscribe_checked', UNDEFINED))
        t = _import_ns.get('t', context.get('t', UNDEFINED))
        cntrller = _import_ns.get('cntrller', context.get('cntrller', UNDEFINED))
        trans = _import_ns.get('trans', context.get('trans', UNDEFINED))
        email = _import_ns.get('email', context.get('email', UNDEFINED))
        __M_writer = context.writer()
        # SOURCE LINE 31
        __M_writer(u'\n\n    ')
        # SOURCE LINE 33

        if form_action is None:
            form_action = h.url_for( controller='user', action='create', cntrller=cntrller )
        from galaxy.web.form_builder import CheckboxField
        subscribe_check_box = CheckboxField( 'subscribe' )
            
        
        # SOURCE LINE 38
        __M_writer(u'\n\n    <div class="toolForm">\n        <form name="registration" id="registration" action="')
        # SOURCE LINE 41
        __M_writer(unicode(form_action))
        __M_writer(u'" method="post" >\n            <div class="toolFormTitle">Create account</div>\n            <div class="form-row">\n                <label>Email address:</label>\n                <input type="text" name="email" value="')
        # SOURCE LINE 45
        __M_writer(filters.html_escape(unicode(email )))
        __M_writer(u'" size="40"/>\n                <input type="hidden" name="redirect" value="')
        # SOURCE LINE 46
        __M_writer(filters.html_escape(unicode(redirect )))
        __M_writer(u'" size="40"/>\n            </div>\n            <div class="form-row">\n                <label>Password:</label>\n                <input type="password" name="password" value="" size="40"/>\n            </div>\n            <div class="form-row">\n                <label>Confirm password:</label>\n                <input type="password" name="confirm" value="" size="40"/>\n            </div>\n            <div class="form-row">\n                <label>Public name:</label>\n                <input type="text" name="username" size="40" value="')
        # SOURCE LINE 58
        __M_writer(filters.html_escape(unicode(username )))
        __M_writer(u'"/>\n')
        # SOURCE LINE 59
        if t.webapp.name == 'galaxy':
            # SOURCE LINE 60
            __M_writer(u'                    <div class="toolParamHelp" style="clear: both;">\n                        Your public name is an identifier that will be used to generate addresses for information\n                        you share publicly. Public names must be at least four characters in length and contain only lower-case\n                        letters, numbers, and the \'-\' character.\n                    </div>\n')
            # SOURCE LINE 65
        else:
            # SOURCE LINE 66
            __M_writer(u'                    <div class="toolParamHelp" style="clear: both;">\n                        Your public name provides a means of identifying you publicly within this tool shed. Public\n                        names must be at least four characters in length and contain only lower-case letters, numbers,\n                        and the \'-\' character.  You cannot change your public name after you have created a repository\n                        in this tool shed.\n                    </div>\n')
            pass
        # SOURCE LINE 73
        __M_writer(u'            </div>\n')
        # SOURCE LINE 74
        if trans.app.config.smtp_server:
            # SOURCE LINE 75
            __M_writer(u'                <div class="form-row">\n                    <label>Subscribe to mailing list:</label>\n')
            # SOURCE LINE 77
            if subscribe_checked:
                # SOURCE LINE 78
                __M_writer(u'                        ')
                subscribe_check_box.checked = True 
                
                __M_writer(u'\n')
                pass
            # SOURCE LINE 80
            __M_writer(u'                    ')
            __M_writer(unicode(subscribe_check_box.get_html()))
            __M_writer(u'\n                    <p>See <a href="http://galaxyproject.org/wiki/Mailing%20Lists" target="_blank">\n                    all Galaxy project mailing lists</a>.</p>\n                </div>\n')
            pass
        # SOURCE LINE 85
        if user_type_fd_id_select_field and len( user_type_fd_id_select_field.options ) > 1:
            # SOURCE LINE 86
            __M_writer(u'                <div class="form-row">\n                    <label>User type</label>\n                    ')
            # SOURCE LINE 88
            __M_writer(unicode(user_type_fd_id_select_field.get_html()))
            __M_writer(u'\n                </div>\n')
            pass
        # SOURCE LINE 91
        if user_type_form_definition:
            # SOURCE LINE 92
            for field in widgets:
                # SOURCE LINE 93
                __M_writer(u'                    <div class="form-row">\n                        <label>')
                # SOURCE LINE 94
                __M_writer(unicode(field['label']))
                __M_writer(u'</label>\n                        ')
                # SOURCE LINE 95
                __M_writer(unicode(field['widget'].get_html()))
                __M_writer(u'\n                        <div class="toolParamHelp" style="clear: both;">\n                            ')
                # SOURCE LINE 97
                __M_writer(unicode(field['helptext']))
                __M_writer(u'\n                        </div>\n                        <div style="clear: both"></div>\n                    </div>\n')
                pass
            # SOURCE LINE 102
            if not user_type_fd_id_select_field:
                # SOURCE LINE 103
                __M_writer(u'                    <input type="hidden" name="user_type_fd_id" value="')
                __M_writer(unicode(trans.security.encode_id( user_type_form_definition.id )))
                __M_writer(u'"/>\n')
                pass
            pass
        # SOURCE LINE 106
        __M_writer(u'            <div class="form-row">\n                <input type="submit" name="create_user_button" value="Submit"/>\n            </div>\n        </form>\n    </div>\n\n')
        return ''
    finally:
        context.caller_stack._pop_frame()
Beispiel #5
0
    def create(self, trans, cntrller='user', redirect_url='', refresh_frames=None, **kwd):
        refresh_frames = refresh_frames or []
        params = util.Params(kwd)
        # If the honeypot field is not empty we are dealing with a bot.
        honeypot_field = params.get('bear_field', '')
        if honeypot_field != '':
            return trans.show_error_message("You've been flagged as a possible bot. If you are not, please try registering again and fill the form out carefully. <a target=\"_top\" href=\"%s\">Go to the home page</a>.") % url_for('/')

        message = util.restore_text(params.get('message', ''))
        status = params.get('status', 'done')
        use_panels = util.string_as_bool(kwd.get('use_panels', True))
        email = util.restore_text(params.get('email', ''))
        # Do not sanitize passwords, so take from kwd
        # instead of params ( which were sanitized )
        password = kwd.get('password', '')
        confirm = kwd.get('confirm', '')
        username = util.restore_text(params.get('username', ''))
        subscribe = params.get('subscribe', '')
        subscribe_checked = CheckboxField.is_checked(subscribe)
        referer = trans.request.referer or ''
        redirect = kwd.get('redirect', referer).strip()
        is_admin = trans.user_is_admin
        success = False
        show_user_prepopulate_form = False
        if not trans.app.config.allow_user_creation and not trans.user_is_admin:
            message = 'User registration is disabled.  Please contact your local Galaxy administrator for an account.'
            if trans.app.config.error_email_to is not None:
                message += f' Contact: {trans.app.config.error_email_to}'
            status = 'error'
        else:
            # check user is allowed to register
            message, status = trans.app.auth_manager.check_registration_allowed(email, username, password)
            if not message:
                # Create the user, save all the user info and login to Galaxy
                if params.get('create_user_button', False):
                    # Check email and password validity
                    message = self.__validate(trans, email, password, confirm, username)
                    if not message:
                        # All the values are valid
                        message, status, user, success = self.__register(trans, subscribe_checked=subscribe_checked, **kwd)
                        if success and not is_admin:
                            # The handle_user_login() method has a call to the history_set_default_permissions() method
                            # (needed when logging in with a history), user needs to have default permissions set before logging in
                            trans.handle_user_login(user)
                            trans.log_event("User created a new account")
                            trans.log_event("User logged in")
                    else:
                        status = 'error'
        registration_warning_message = trans.app.config.registration_warning_message
        if success:
            if is_admin:
                redirect_url = web.url_for('/admin/users?status=success&message=Created new user account.')
            else:
                redirect_url = web.url_for('/')
        return trans.fill_template('/webapps/tool_shed/user/register.mako',
                                   cntrller=cntrller,
                                   email=email,
                                   username=username,
                                   subscribe_checked=subscribe_checked,
                                   show_user_prepopulate_form=show_user_prepopulate_form,
                                   use_panels=use_panels,
                                   redirect=redirect,
                                   redirect_url=redirect_url,
                                   refresh_frames=refresh_frames,
                                   registration_warning_message=registration_warning_message,
                                   message=message,
                                   status=status)
def render_render_registration_form(context,form_action=None):
    context.caller_stack._push_frame()
    try:
        _import_ns = {}
        _mako_get_namespace(context, '__anon_0x28802690')._populate(_import_ns, [u'render_msg'])
        username = _import_ns.get('username', context.get('username', UNDEFINED))
        redirect = _import_ns.get('redirect', context.get('redirect', UNDEFINED))
        user_type_form_definition = _import_ns.get('user_type_form_definition', context.get('user_type_form_definition', UNDEFINED))
        h = _import_ns.get('h', context.get('h', UNDEFINED))
        registration_warning_message = _import_ns.get('registration_warning_message', context.get('registration_warning_message', UNDEFINED))
        len = _import_ns.get('len', context.get('len', UNDEFINED))
        user_type_fd_id_select_field = _import_ns.get('user_type_fd_id_select_field', context.get('user_type_fd_id_select_field', UNDEFINED))
        widgets = _import_ns.get('widgets', context.get('widgets', UNDEFINED))
        subscribe_checked = _import_ns.get('subscribe_checked', context.get('subscribe_checked', UNDEFINED))
        t = _import_ns.get('t', context.get('t', UNDEFINED))
        cntrller = _import_ns.get('cntrller', context.get('cntrller', UNDEFINED))
        trans = _import_ns.get('trans', context.get('trans', UNDEFINED))
        email = _import_ns.get('email', context.get('email', UNDEFINED))
        __M_writer = context.writer()
        # SOURCE LINE 31
        __M_writer(u'\n\n    ')
        # SOURCE LINE 33

        if form_action is None:
            form_action = h.url_for( controller='user', action='create', cntrller=cntrller )
        from galaxy.web.form_builder import CheckboxField
        subscribe_check_box = CheckboxField( 'subscribe' )
            
        
        # SOURCE LINE 38
        __M_writer(u'\n\n<script type="text/javascript">\n\t$(document).ready(function() {\n\n\t\tfunction validateString(test_string, type) { \n\t\t\tvar mail_re = /^(([^<>()[\\]\\\\.,;:\\s@\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\"]+)*)|(\\".+\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n\t\t\t//var mail_re_RFC822 = /^([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x22([^\\x0d\\x22\\x5c\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x22)(\\x2e([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x22([^\\x0d\\x22\\x5c\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x22))*\\x40([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x5b([^\\x0d\\x5b-\\x5d\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x5d)(\\x2e([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x5b([^\\x0d\\x5b-\\x5d\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x5d))*$/;\n\t\t\tvar username_re = /^[a-z0-9\\-]{3,255}$/;\n\t\t\tif (type === \'email\') {\n\t\t\t\treturn mail_re.test(test_string);\n\t\t\t} else if (type === \'username\'){\n\t\t\t\treturn username_re.test(test_string);\n\t\t\t}\n\t\t} \n\n\t\tfunction renderError(message) {\n\t\tif ($(".errormessage").length === 1) {\n\t\t\t$(".errormessage").html(message)\n\t\t} else {\n\t\t\tvar div = document.createElement("div");\n\t\t\tdiv.className = "errormessage";\n\t\t\tdiv.innerHTML = message;\n\t\t\tdocument.body.insertBefore(div, document.body.firstChild);\n\t\t\t}\n\t\t}\n\n\t\t$(\'#registration\').bind(\'submit\', function(e) {\n\t\t\t$(\'#send\').attr(\'disabled\', \'disabled\');\n            \n            // we need this value to detect submitting at backend\n\t\t\tvar hidden_input = \'<input type="hidden" id="create_user_button" name="create_user_button" value="Submit"/>\';\n\t\t\t$("#email_input").before(hidden_input);\n\n\t\t\tvar error_text_email= \'Please enter your valid email address\';\n\t\t\tvar error_text_email_long= \'Email cannot be more than 255 characters in length\';\n\t\t\tvar error_text_username_characters = \'Public name must contain only lowercase letters, numbers and "-". It also has to be shorter than 255 characters but longer than 3.\';\n\t\t\tvar error_text_password_short = \'Please use a password of at least 6 characters\';\n\t\t\tvar error_text_password_match = "Passwords don\'t match";\n\n\t\t    var validForm = true;\n\t\t    \n\t\t    var email = $(\'#email_input\').val();\n\t\t    var name = $(\'#name_input\').val();\n\t\t    if (email.length > 255){ renderError(error_text_email_long); validForm = false;}\n\t\t    else if (!validateString(email,"email")){ renderError(error_text_email); validForm = false;}\n\t\t    else if (!($(\'#password_input\').val() === $(\'#password_check_input\').val())){ renderError(error_text_password_match); validForm = false;}\n\t\t    else if ($(\'#password_input\').val().length < 6 ){ renderError(error_text_password_short); validForm = false;}\n\t\t    else if (name && !(validateString(name,"username"))){ renderError(error_text_username_characters); validForm = false;}\n\n\t   \t\tif (!validForm) { \n\t\t        e.preventDefault();\n\t\t        // reactivate the button if the form wasn\'t submitted\n\t\t        $(\'#send\').removeAttr(\'disabled\');\n\t\t        }\n\t\t\t});\n\t});\n\n</script>\n    <div class="toolForm">\n        <form name="registration" id="registration" action="')
        # SOURCE LINE 98
        __M_writer(unicode(form_action))
        __M_writer(u'" method="post" >\n            <div class="toolFormTitle">Create account</div>\n            <div class="form-row">\n                <label>Email address:</label>\n                <input id="email_input" type="text" name="email" value="')
        # SOURCE LINE 102
        __M_writer(filters.html_escape(unicode(email )))
        __M_writer(u'" size="40"/>\n                <input type="hidden" name="redirect" value="')
        # SOURCE LINE 103
        __M_writer(filters.html_escape(unicode(redirect )))
        __M_writer(u'" size="40"/>\n            </div>\n            <div class="form-row">\n                <label>Password:</label>\n                <input id="password_input" type="password" name="password" value="" size="40"/>\n            </div>\n            <div class="form-row">\n                <label>Confirm password:</label>\n                <input id="password_check_input" type="password" name="confirm" value="" size="40"/>\n            </div>\n            <div class="form-row">\n                <label>Public name:</label>\n                <input id="name_input" type="text" name="username" size="40" value="')
        # SOURCE LINE 115
        __M_writer(filters.html_escape(unicode(username )))
        __M_writer(u'"/>\n')
        # SOURCE LINE 116
        if t.webapp.name == 'galaxy':
            # SOURCE LINE 117
            __M_writer(u'                    <div class="toolParamHelp" style="clear: both;">\n                        Your public name is an identifier that will be used to generate addresses for information\n                        you share publicly. Public names must be at least four characters in length and contain only lower-case\n                        letters, numbers, and the \'-\' character.\n                    </div>\n')
            # SOURCE LINE 122
        else:
            # SOURCE LINE 123
            __M_writer(u'                    <div class="toolParamHelp" style="clear: both;">\n                        Your public name provides a means of identifying you publicly within this tool shed. Public\n                        names must be at least four characters in length and contain only lower-case letters, numbers,\n                        and the \'-\' character.  You cannot change your public name after you have created a repository\n                        in this tool shed.\n                    </div>\n')
            pass
        # SOURCE LINE 130
        __M_writer(u'            </div>\n')
        # SOURCE LINE 131
        if trans.app.config.smtp_server:
            # SOURCE LINE 132
            __M_writer(u'                <div class="form-row">\n                    <label>Subscribe to mailing list:</label>\n')
            # SOURCE LINE 134
            if subscribe_checked:
                # SOURCE LINE 135
                __M_writer(u'                        ')
                subscribe_check_box.checked = True 
                
                __M_writer(u'\n')
                pass
            # SOURCE LINE 137
            __M_writer(u'                    ')
            __M_writer(unicode(subscribe_check_box.get_html()))
            __M_writer(u'\n                    <p>See <a href="http://galaxyproject.org/wiki/Mailing%20Lists" target="_blank">\n                    all Galaxy project mailing lists</a>.</p>\n                </div>\n')
            pass
        # SOURCE LINE 142
        if user_type_fd_id_select_field and len( user_type_fd_id_select_field.options ) >= 1:
            # SOURCE LINE 143
            __M_writer(u'                <div class="form-row">\n                    <label>User type</label>\n                    ')
            # SOURCE LINE 145
            __M_writer(unicode(user_type_fd_id_select_field.get_html()))
            __M_writer(u'\n                </div>\n')
            pass
        # SOURCE LINE 148
        if user_type_form_definition:
            # SOURCE LINE 149
            for field in widgets:
                # SOURCE LINE 150
                __M_writer(u'                    <div class="form-row">\n                        <label>')
                # SOURCE LINE 151
                __M_writer(unicode(field['label']))
                __M_writer(u'</label>\n                        ')
                # SOURCE LINE 152
                __M_writer(unicode(field['widget'].get_html()))
                __M_writer(u'\n                        <div class="toolParamHelp" style="clear: both;">\n                            ')
                # SOURCE LINE 154
                __M_writer(unicode(field['helptext']))
                __M_writer(u'\n                        </div>\n                        <div style="clear: both"></div>\n                    </div>\n')
                pass
            # SOURCE LINE 159
            if not user_type_fd_id_select_field:
                # SOURCE LINE 160
                __M_writer(u'                    <input type="hidden" name="user_type_fd_id" value="')
                __M_writer(unicode(trans.security.encode_id( user_type_form_definition.id )))
                __M_writer(u'"/>\n')
                pass
            pass
        # SOURCE LINE 163
        __M_writer(u'            <div id="for_bears">\n            If you see this, please leave following field blank. \n            <input type="text" name="bear_field" size="1" value=""/>\n            </div>\n            <div class="form-row">\n                <input type="submit" id="send" name="create_user_button" value="Submit"/>\n            </div>\n        </form>\n')
        # SOURCE LINE 171
        if registration_warning_message:
            # SOURCE LINE 172
            __M_writer(u'        <div class="alert alert-danger" style="margin: 30px 12px 12px 12px;">\n            ')
            # SOURCE LINE 173
            __M_writer(unicode(registration_warning_message))
            __M_writer(u'           \n        </div>\n')
            pass
        # SOURCE LINE 176
        __M_writer(u'    </div>\n\n')
        return ''
    finally:
        context.caller_stack._pop_frame()
Beispiel #7
0
def render_render_registration_form(context, form_action=None):
    __M_caller = context.caller_stack._push_frame()
    try:
        _import_ns = {}
        _mako_get_namespace(context, '__anon_0x7f295c474e50')._populate(
            _import_ns, [u'render_msg'])
        username = _import_ns.get('username',
                                  context.get('username', UNDEFINED))
        redirect = _import_ns.get('redirect',
                                  context.get('redirect', UNDEFINED))
        h = _import_ns.get('h', context.get('h', UNDEFINED))
        registration_warning_message = _import_ns.get(
            'registration_warning_message',
            context.get('registration_warning_message', UNDEFINED))
        subscribe_checked = _import_ns.get(
            'subscribe_checked', context.get('subscribe_checked', UNDEFINED))
        t = _import_ns.get('t', context.get('t', UNDEFINED))
        cntrller = _import_ns.get('cntrller',
                                  context.get('cntrller', UNDEFINED))
        trans = _import_ns.get('trans', context.get('trans', UNDEFINED))
        email = _import_ns.get('email', context.get('email', UNDEFINED))
        __M_writer = context.writer()
        __M_writer(u'\n\n    ')

        if form_action is None:
            form_action = h.url_for(controller='user',
                                    action='create',
                                    cntrller=cntrller)
        from galaxy.web.form_builder import CheckboxField
        subscribe_check_box = CheckboxField('subscribe')

        __M_writer(
            u'\n\n    <script type="text/javascript">\n        $(document).ready(function() {\n\n            function validateString(test_string, type) {\n                var mail_re = /^(([^<>()[\\]\\\\.,;:\\s@\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\"]+)*)|(\\".+\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n                //var mail_re_RFC822 = /^([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x22([^\\x0d\\x22\\x5c\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x22)(\\x2e([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x22([^\\x0d\\x22\\x5c\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x22))*\\x40([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x5b([^\\x0d\\x5b-\\x5d\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x5d)(\\x2e([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x5b([^\\x0d\\x5b-\\x5d\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x5d))*$/;\n                var username_re = /^[a-z0-9._\\-]{3,255}$/;\n                if (type === \'email\') {\n                    return mail_re.test(test_string);\n                } else if (type === \'username\'){\n                    return username_re.test(test_string);\n                }\n            }\n\n            function renderError(message) {\n                if (!$(".errormessage").size()) {\n                    $(\'<div/>\').addClass(\'errormessage\').insertBefore(\'#registrationForm\');\n                }\n                console.debug( $( \'#registrationForm\' ) );\n                console.debug( \'.errormessage:\', $( \'.errormessage\' ) );\n                $(".errormessage").html(message);\n            }\n\n            $("[name=\'password\']").complexify({\'minimumChars\':6}, function(valid, complexity){\n                var progressBar = $(\'.progress-bar\');\n                var color = valid ? \'lightgreen\' : \'red\';\n\n                progressBar.css(\'background-color\', color);\n                progressBar.css({\'width\': complexity + \'%\'});\n            });\n\n            $(\'#registration\').bind(\'submit\', function(e) {\n                $(\'#send\').attr(\'disabled\', \'disabled\');\n\n                // we need this value to detect submitting at backend\n                var hidden_input = \'<input type="hidden" id="create_user_button" name="create_user_button" value="Submit"/>\';\n                $("#email_input").before(hidden_input);\n\n                var error_text_email = \'The format of the email address is not correct.\';\n                var error_text_email_long = \'Email address cannot be more than 255 characters in length.\';\n                var error_text_username_characters = "Public name must contain only lowercase letters, numbers, \'.\', \'_\' and \'-\'. It also has to be between 3 and 255 characters in length.";\n                var error_text_password_short = \'Use a password of at least 6 characters\';\n                var error_text_password_match = "Passwords don\'t match";\n\n                var validForm = true;\n\n                var email = $(\'#email_input\').val();\n                var name = $(\'#name_input\').val();\n                if (email.length > 255){ renderError(error_text_email_long); validForm = false;}\n                else if (!validateString(email,"email")){ renderError(error_text_email); validForm = false;}\n                else if (!($(\'#password_input\').val() === $(\'#password_check_input\').val())){ renderError(error_text_password_match); validForm = false;}\n                else if ($(\'#password_input\').val().length < 6 ){ renderError(error_text_password_short); validForm = false;}\n                else if (name && !(validateString(name,"username"))){ renderError(error_text_username_characters); validForm = false;}\n\n                   if (!validForm) {\n                    e.preventDefault();\n                    // reactivate the button if the form wasn\'t submitted\n                    $(\'#send\').removeAttr(\'disabled\');\n                    }\n                });\n        });\n    </script>\n\n    <div id="registrationForm" class="toolForm">\n        <form name="registration" id="registration" action="'
        )
        __M_writer(unicode(form_action))
        __M_writer(
            u'" method="post" >\n            <div class="toolFormTitle">Create account</div>\n            <div class="form-row">\n                <label>Email address:</label>\n                <input id="email_input" type="text" name="email" value="'
        )
        __M_writer(filters.html_escape(unicode(email)))
        __M_writer(
            u'" size="40"/>\n                <input type="hidden" name="redirect" value="'
        )
        __M_writer(filters.html_escape(unicode(redirect)))
        __M_writer(
            u'" size="40"/>\n            </div>\n            <div class="form-row">\n                <label>Password:</label>\n                <input id="password_input" type="password" name="password" value="" size="40"/>\n            </div>\n            <div class="progress">\n                <div id="complexity-bar" class="progress-bar" role="progressbar">\n                    Strength\n                </div>\n            </div>\n            <div class="form-row">\n                <label>Confirm password:</label>\n                <input id="password_check_input" type="password" name="confirm" value="" size="40"/>\n            </div>\n            <div class="form-row">\n                <label>Public name:</label>\n                <input id="name_input" type="text" name="username" size="40" value="'
        )
        __M_writer(filters.html_escape(unicode(username)))
        __M_writer(u'"/>\n')
        if t.webapp.name == 'galaxy':
            __M_writer(
                u'                    <div class="toolParamHelp" style="clear: both;">\n                        Your public name is an identifier that will be used to generate addresses for information\n                        you share publicly. Public names must be at least three characters in length and contain only\n                        lower-case letters, numbers, dots, underscores, and dashes (\'.\', \'_\', \'-\').\n                    </div>\n'
            )
        else:
            __M_writer(
                u'                    <div class="toolParamHelp" style="clear: both;">\n                        Your public name provides a means of identifying you publicly within this tool shed. Public\n                        names must be at least three characters in length and contain only lower-case letters, numbers,\n                        dots, underscores, and dashes (\'.\', \'_\', \'-\'). You cannot change your public name after you have\n                        created a repository in this Tool Shed.\n                    </div>\n'
            )
        __M_writer(u'            </div>\n')
        if trans.app.config.smtp_server and trans.app.config.mailing_join_addr:
            __M_writer(
                u'                <div class="form-row">\n                    <label>Subscribe to mailing list:</label>\n'
            )
            if subscribe_checked:
                __M_writer(u'                        ')
                subscribe_check_box.checked = True

                __M_writer(u'\n')
            __M_writer(u'                    ')
            __M_writer(unicode(subscribe_check_box.get_html()))
            __M_writer(
                u'\n                    <p>See <a href="http://galaxyproject.org/wiki/Mailing%20Lists" target="_blank">\n                    all Galaxy project mailing lists</a>.</p>\n                </div>\n'
            )
        __M_writer(
            u'            <div id="for_bears">\n            If you see this, please leave following field blank.\n            <input type="text" name="bear_field" size="1" value=""/>\n            </div>\n            <div class="form-row">\n                <input type="submit" id="send" name="create_user_button" value="Submit"/>\n            </div>\n        </form>\n'
        )
        if registration_warning_message:
            __M_writer(
                u'        <div class="alert alert-danger" style="margin: 30px 12px 12px 12px;">\n            '
            )
            __M_writer(unicode(registration_warning_message))
            __M_writer(u'\n        </div>\n')
        __M_writer(u'    </div>\n\n')
        return ''
    finally:
        context.caller_stack._pop_frame()
def render_body(context,**pageargs):
    context.caller_stack._push_frame()
    try:
        __M_locals = __M_dict_builtin(pageargs=pageargs)
        _import_ns = {}
        _mako_get_namespace(context, '__anon_0x15b7f310')._populate(_import_ns, [u'render_msg'])
        status = _import_ns.get('status', context.get('status', UNDEFINED))
        render_msg = _import_ns.get('render_msg', context.get('render_msg', UNDEFINED))
        name = _import_ns.get('name', context.get('name', UNDEFINED))
        in_users = _import_ns.get('in_users', context.get('in_users', UNDEFINED))
        h = _import_ns.get('h', context.get('h', UNDEFINED))
        def render_select(name,options):
            return render_render_select(context.locals_(__M_locals),name,options)
        create_group_for_role_checked = _import_ns.get('create_group_for_role_checked', context.get('create_group_for_role_checked', UNDEFINED))
        out_groups = _import_ns.get('out_groups', context.get('out_groups', UNDEFINED))
        in_groups = _import_ns.get('in_groups', context.get('in_groups', UNDEFINED))
        out_users = _import_ns.get('out_users', context.get('out_users', UNDEFINED))
        message = _import_ns.get('message', context.get('message', UNDEFINED))
        description = _import_ns.get('description', context.get('description', UNDEFINED))
        __M_writer = context.writer()
        # SOURCE LINE 1
        __M_writer(u'\n')
        # SOURCE LINE 2
        __M_writer(u'\n\n')
        # SOURCE LINE 11
        __M_writer(u'\n\n')
        # SOURCE LINE 19
        __M_writer(u'\n\n<script type="text/javascript">\n    $().ready(function() {  \n        $(\'#groups_add_button\').click(function() {\n            return !$(\'#out_groups option:selected\').remove().appendTo(\'#in_groups\');\n        });\n        $(\'#groups_remove_button\').click(function() {\n            return !$(\'#in_groups option:selected\').remove().appendTo(\'#out_groups\');\n        });\n        $(\'#users_add_button\').click(function() {\n            return !$(\'#out_users option:selected\').remove().appendTo(\'#in_users\');\n        });\n        $(\'#users_remove_button\').click(function() {\n            return !$(\'#in_users option:selected\').remove().appendTo(\'#out_users\');\n        });\n        $(\'form#associate_role_group_user\').submit(function() {\n            $(\'#in_groups option\').each(function(i) {\n                $(this).attr("selected", "selected");\n            });\n            $(\'#in_users option\').each(function(i) {\n                $(this).attr("selected", "selected");\n            });\n        });\n        //Temporary removal of select2 for inputs -- refactor this later.\n        $(\'select\').select2("destroy");\n    });\n</script>\n\n')
        # SOURCE LINE 48

        from galaxy.web.form_builder import CheckboxField
        create_group_for_role_checkbox = CheckboxField( 'create_group_for_role' )
        
        
        __M_locals_builtin_stored = __M_locals_builtin()
        __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['create_group_for_role_checkbox','CheckboxField'] if __M_key in __M_locals_builtin_stored]))
        # SOURCE LINE 51
        __M_writer(u'\n\n')
        # SOURCE LINE 53
        if message:
            # SOURCE LINE 54
            __M_writer(u'    ')
            __M_writer(unicode(render_msg( message, status )))
            __M_writer(u'\n')
            pass
        # SOURCE LINE 56
        __M_writer(u'\n<div class="toolForm">\n    <div class="toolFormTitle">Create Role</div>\n    <div class="toolFormBody">\n        <form name="associate_role_group_user" id="associate_role_group_user" action="')
        # SOURCE LINE 60
        __M_writer(unicode(h.url_for(controller='admin', action='create_role' )))
        __M_writer(u'" method="post" >\n            <div class="form-row">\n                <label>Name:</label>\n                <input  name="name" type="textfield" value="')
        # SOURCE LINE 63
        __M_writer(unicode(name))
        __M_writer(u'" size=40"/>\n            </div>\n            <div class="form-row">\n                <label>Description:</label>\n                <input  name="description" type="textfield" value="')
        # SOURCE LINE 67
        __M_writer(unicode(description))
        __M_writer(u'" size=40"/>\n            </div>\n            <div class="form-row">\n                <div style="float: left; margin-right: 10px;">\n                    <label>Groups associated with new role</label>\n                    ')
        # SOURCE LINE 72
        __M_writer(unicode(render_select( "in_groups", in_groups )))
        __M_writer(u'<br/>\n                    <input type="submit" id="groups_remove_button" value=">>"/>\n                </div>\n                <div>\n                    <label>Groups not associated with new role</label>\n                    ')
        # SOURCE LINE 77
        __M_writer(unicode(render_select( "out_groups", out_groups )))
        __M_writer(u'<br/>\n                    <input type="submit" id="groups_add_button" value="<<"/>\n                </div>\n            </div>\n            <div class="form-row">\n                <div style="float: left; margin-right: 10px;">\n                    <label>Users associated with new role</label>\n                    ')
        # SOURCE LINE 84
        __M_writer(unicode(render_select( "in_users", in_users )))
        __M_writer(u'<br/>\n                    <input type="submit" id="users_remove_button" value=">>"/>\n                </div>\n                <div>\n                    <label>Users not associated with new role</label>\n                    ')
        # SOURCE LINE 89
        __M_writer(unicode(render_select( "out_users", out_users )))
        __M_writer(u'<br/>\n                    <input type="submit" id="users_add_button" value="<<"/>\n                </div>\n            </div>\n            <div class="form-row">\n')
        # SOURCE LINE 94
        if create_group_for_role_checked:
            # SOURCE LINE 95
            __M_writer(u'                    ')
            create_group_for_role_checkbox.checked = True 
            
            __M_locals_builtin_stored = __M_locals_builtin()
            __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in [] if __M_key in __M_locals_builtin_stored]))
            __M_writer(u'\n')
            pass
        # SOURCE LINE 97
        __M_writer(u'                ')
        __M_writer(unicode(create_group_for_role_checkbox.get_html()))
        __M_writer(u' Create a new group of the same name for this role\n            </div>\n            <div class="form-row">\n                <input type="submit" name="create_role_button" value="Save"/>\n            </div>\n        </form>\n    </div>\n</div>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()
def render_render_registration_form(context, form_action=None):
    context.caller_stack._push_frame()
    try:
        _import_ns = {}
        _mako_get_namespace(context, '__anon_0x28802690')._populate(
            _import_ns, [u'render_msg'])
        username = _import_ns.get('username',
                                  context.get('username', UNDEFINED))
        redirect = _import_ns.get('redirect',
                                  context.get('redirect', UNDEFINED))
        user_type_form_definition = _import_ns.get(
            'user_type_form_definition',
            context.get('user_type_form_definition', UNDEFINED))
        h = _import_ns.get('h', context.get('h', UNDEFINED))
        registration_warning_message = _import_ns.get(
            'registration_warning_message',
            context.get('registration_warning_message', UNDEFINED))
        len = _import_ns.get('len', context.get('len', UNDEFINED))
        user_type_fd_id_select_field = _import_ns.get(
            'user_type_fd_id_select_field',
            context.get('user_type_fd_id_select_field', UNDEFINED))
        widgets = _import_ns.get('widgets', context.get('widgets', UNDEFINED))
        subscribe_checked = _import_ns.get(
            'subscribe_checked', context.get('subscribe_checked', UNDEFINED))
        t = _import_ns.get('t', context.get('t', UNDEFINED))
        cntrller = _import_ns.get('cntrller',
                                  context.get('cntrller', UNDEFINED))
        trans = _import_ns.get('trans', context.get('trans', UNDEFINED))
        email = _import_ns.get('email', context.get('email', UNDEFINED))
        __M_writer = context.writer()
        # SOURCE LINE 31
        __M_writer(u'\n\n    ')
        # SOURCE LINE 33

        if form_action is None:
            form_action = h.url_for(controller='user',
                                    action='create',
                                    cntrller=cntrller)
        from galaxy.web.form_builder import CheckboxField
        subscribe_check_box = CheckboxField('subscribe')

        # SOURCE LINE 38
        __M_writer(
            u'\n\n<script type="text/javascript">\n\t$(document).ready(function() {\n\n\t\tfunction validateString(test_string, type) { \n\t\t\tvar mail_re = /^(([^<>()[\\]\\\\.,;:\\s@\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\"]+)*)|(\\".+\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n\t\t\t//var mail_re_RFC822 = /^([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x22([^\\x0d\\x22\\x5c\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x22)(\\x2e([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x22([^\\x0d\\x22\\x5c\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x22))*\\x40([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x5b([^\\x0d\\x5b-\\x5d\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x5d)(\\x2e([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x5b([^\\x0d\\x5b-\\x5d\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x5d))*$/;\n\t\t\tvar username_re = /^[a-z0-9\\-]{3,255}$/;\n\t\t\tif (type === \'email\') {\n\t\t\t\treturn mail_re.test(test_string);\n\t\t\t} else if (type === \'username\'){\n\t\t\t\treturn username_re.test(test_string);\n\t\t\t}\n\t\t} \n\n\t\tfunction renderError(message) {\n\t\tif ($(".errormessage").length === 1) {\n\t\t\t$(".errormessage").html(message)\n\t\t} else {\n\t\t\tvar div = document.createElement("div");\n\t\t\tdiv.className = "errormessage";\n\t\t\tdiv.innerHTML = message;\n\t\t\tdocument.body.insertBefore(div, document.body.firstChild);\n\t\t\t}\n\t\t}\n\n\t\t$(\'#registration\').bind(\'submit\', function(e) {\n\t\t\t$(\'#send\').attr(\'disabled\', \'disabled\');\n            \n            // we need this value to detect submitting at backend\n\t\t\tvar hidden_input = \'<input type="hidden" id="create_user_button" name="create_user_button" value="Submit"/>\';\n\t\t\t$("#email_input").before(hidden_input);\n\n\t\t\tvar error_text_email= \'Please enter your valid email address\';\n\t\t\tvar error_text_email_long= \'Email cannot be more than 255 characters in length\';\n\t\t\tvar error_text_username_characters = \'Public name must contain only lowercase letters, numbers and "-". It also has to be shorter than 255 characters but longer than 3.\';\n\t\t\tvar error_text_password_short = \'Please use a password of at least 6 characters\';\n\t\t\tvar error_text_password_match = "Passwords don\'t match";\n\n\t\t    var validForm = true;\n\t\t    \n\t\t    var email = $(\'#email_input\').val();\n\t\t    var name = $(\'#name_input\').val();\n\t\t    if (email.length > 255){ renderError(error_text_email_long); validForm = false;}\n\t\t    else if (!validateString(email,"email")){ renderError(error_text_email); validForm = false;}\n\t\t    else if (!($(\'#password_input\').val() === $(\'#password_check_input\').val())){ renderError(error_text_password_match); validForm = false;}\n\t\t    else if ($(\'#password_input\').val().length < 6 ){ renderError(error_text_password_short); validForm = false;}\n\t\t    else if (name && !(validateString(name,"username"))){ renderError(error_text_username_characters); validForm = false;}\n\n\t   \t\tif (!validForm) { \n\t\t        e.preventDefault();\n\t\t        // reactivate the button if the form wasn\'t submitted\n\t\t        $(\'#send\').removeAttr(\'disabled\');\n\t\t        }\n\t\t\t});\n\t});\n\n</script>\n    <div class="toolForm">\n        <form name="registration" id="registration" action="'
        )
        # SOURCE LINE 98
        __M_writer(unicode(form_action))
        __M_writer(
            u'" method="post" >\n            <div class="toolFormTitle">Create account</div>\n            <div class="form-row">\n                <label>Email address:</label>\n                <input id="email_input" type="text" name="email" value="'
        )
        # SOURCE LINE 102
        __M_writer(filters.html_escape(unicode(email)))
        __M_writer(
            u'" size="40"/>\n                <input type="hidden" name="redirect" value="'
        )
        # SOURCE LINE 103
        __M_writer(filters.html_escape(unicode(redirect)))
        __M_writer(
            u'" size="40"/>\n            </div>\n            <div class="form-row">\n                <label>Password:</label>\n                <input id="password_input" type="password" name="password" value="" size="40"/>\n            </div>\n            <div class="form-row">\n                <label>Confirm password:</label>\n                <input id="password_check_input" type="password" name="confirm" value="" size="40"/>\n            </div>\n            <div class="form-row">\n                <label>Public name:</label>\n                <input id="name_input" type="text" name="username" size="40" value="'
        )
        # SOURCE LINE 115
        __M_writer(filters.html_escape(unicode(username)))
        __M_writer(u'"/>\n')
        # SOURCE LINE 116
        if t.webapp.name == 'galaxy':
            # SOURCE LINE 117
            __M_writer(
                u'                    <div class="toolParamHelp" style="clear: both;">\n                        Your public name is an identifier that will be used to generate addresses for information\n                        you share publicly. Public names must be at least four characters in length and contain only lower-case\n                        letters, numbers, and the \'-\' character.\n                    </div>\n'
            )
            # SOURCE LINE 122
        else:
            # SOURCE LINE 123
            __M_writer(
                u'                    <div class="toolParamHelp" style="clear: both;">\n                        Your public name provides a means of identifying you publicly within this tool shed. Public\n                        names must be at least four characters in length and contain only lower-case letters, numbers,\n                        and the \'-\' character.  You cannot change your public name after you have created a repository\n                        in this tool shed.\n                    </div>\n'
            )
            pass
        # SOURCE LINE 130
        __M_writer(u'            </div>\n')
        # SOURCE LINE 131
        if trans.app.config.smtp_server:
            # SOURCE LINE 132
            __M_writer(
                u'                <div class="form-row">\n                    <label>Subscribe to mailing list:</label>\n'
            )
            # SOURCE LINE 134
            if subscribe_checked:
                # SOURCE LINE 135
                __M_writer(u'                        ')
                subscribe_check_box.checked = True

                __M_writer(u'\n')
                pass
            # SOURCE LINE 137
            __M_writer(u'                    ')
            __M_writer(unicode(subscribe_check_box.get_html()))
            __M_writer(
                u'\n                    <p>See <a href="http://galaxyproject.org/wiki/Mailing%20Lists" target="_blank">\n                    all Galaxy project mailing lists</a>.</p>\n                </div>\n'
            )
            pass
        # SOURCE LINE 142
        if user_type_fd_id_select_field and len(
                user_type_fd_id_select_field.options) >= 1:
            # SOURCE LINE 143
            __M_writer(
                u'                <div class="form-row">\n                    <label>User type</label>\n                    '
            )
            # SOURCE LINE 145
            __M_writer(unicode(user_type_fd_id_select_field.get_html()))
            __M_writer(u'\n                </div>\n')
            pass
        # SOURCE LINE 148
        if user_type_form_definition:
            # SOURCE LINE 149
            for field in widgets:
                # SOURCE LINE 150
                __M_writer(
                    u'                    <div class="form-row">\n                        <label>'
                )
                # SOURCE LINE 151
                __M_writer(unicode(field['label']))
                __M_writer(u'</label>\n                        ')
                # SOURCE LINE 152
                __M_writer(unicode(field['widget'].get_html()))
                __M_writer(
                    u'\n                        <div class="toolParamHelp" style="clear: both;">\n                            '
                )
                # SOURCE LINE 154
                __M_writer(unicode(field['helptext']))
                __M_writer(
                    u'\n                        </div>\n                        <div style="clear: both"></div>\n                    </div>\n'
                )
                pass
            # SOURCE LINE 159
            if not user_type_fd_id_select_field:
                # SOURCE LINE 160
                __M_writer(
                    u'                    <input type="hidden" name="user_type_fd_id" value="'
                )
                __M_writer(
                    unicode(
                        trans.security.encode_id(
                            user_type_form_definition.id)))
                __M_writer(u'"/>\n')
                pass
            pass
        # SOURCE LINE 163
        __M_writer(
            u'            <div id="for_bears">\n            If you see this, please leave following field blank. \n            <input type="text" name="bear_field" size="1" value=""/>\n            </div>\n            <div class="form-row">\n                <input type="submit" id="send" name="create_user_button" value="Submit"/>\n            </div>\n        </form>\n'
        )
        # SOURCE LINE 171
        if registration_warning_message:
            # SOURCE LINE 172
            __M_writer(
                u'        <div class="alert alert-danger" style="margin: 30px 12px 12px 12px;">\n            '
            )
            # SOURCE LINE 173
            __M_writer(unicode(registration_warning_message))
            __M_writer(u'           \n        </div>\n')
            pass
        # SOURCE LINE 176
        __M_writer(u'    </div>\n\n')
        return ''
    finally:
        context.caller_stack._pop_frame()
Beispiel #10
0
def render_render_registration_form(context,form_action=None):
    context.caller_stack._push_frame()
    try:
        _import_ns = {}
        _mako_get_namespace(context, '__anon_0x6877ad0')._populate(_import_ns, [u'render_msg'])
        username = _import_ns.get('username', context.get('username', UNDEFINED))
        trans = _import_ns.get('trans', context.get('trans', UNDEFINED))
        user_type_form_definition = _import_ns.get('user_type_form_definition', context.get('user_type_form_definition', UNDEFINED))
        confirm = _import_ns.get('confirm', context.get('confirm', UNDEFINED))
        h = _import_ns.get('h', context.get('h', UNDEFINED))
        user_type_fd_id_select_field = _import_ns.get('user_type_fd_id_select_field', context.get('user_type_fd_id_select_field', UNDEFINED))
        widgets = _import_ns.get('widgets', context.get('widgets', UNDEFINED))
        subscribe_checked = _import_ns.get('subscribe_checked', context.get('subscribe_checked', UNDEFINED))
        referer = _import_ns.get('referer', context.get('referer', UNDEFINED))
        cntrller = _import_ns.get('cntrller', context.get('cntrller', UNDEFINED))
        webapp = _import_ns.get('webapp', context.get('webapp', UNDEFINED))
        password = _import_ns.get('password', context.get('password', UNDEFINED))
        email = _import_ns.get('email', context.get('email', UNDEFINED))
        __M_writer = context.writer()
        # SOURCE LINE 24
        __M_writer(u'\n\n    ')
        # SOURCE LINE 26

        if form_action is None:
            form_action = h.url_for( controller='user', action='create', cntrller=cntrller )
        from galaxy.web.form_builder import CheckboxField
        subscribe_check_box = CheckboxField( 'subscribe' )
            
        
        # SOURCE LINE 31
        __M_writer(u'\n\n    <div class="toolForm">\n        <form name="registration" id="registration" action="')
        # SOURCE LINE 34
        __M_writer(unicode(form_action))
        __M_writer(u'" method="post" >\n            <div class="toolFormTitle">Create account</div>\n            <div class="form-row">\n                <label>Email address:</label>\n                <input type="text" name="email" value="')
        # SOURCE LINE 38
        __M_writer(unicode(email))
        __M_writer(u'" size="40"/>\n                <input type="hidden" name="webapp" value="')
        # SOURCE LINE 39
        __M_writer(unicode(webapp))
        __M_writer(u'" size="40"/>\n                <input type="hidden" name="referer" value="')
        # SOURCE LINE 40
        __M_writer(unicode(referer))
        __M_writer(u'" size="40"/>\n            </div>\n            <div class="form-row">\n                <label>Password:</label>\n                <input type="password" name="password" value="')
        # SOURCE LINE 44
        __M_writer(unicode(password))
        __M_writer(u'" size="40"/>\n            </div>\n            <div class="form-row">\n                <label>Confirm password:</label>\n                <input type="password" name="confirm" value="')
        # SOURCE LINE 48
        __M_writer(unicode(confirm))
        __M_writer(u'" size="40"/>\n            </div>\n            <div class="form-row">\n                <label>Public name:</label>\n                <input type="text" name="username" size="40" value="')
        # SOURCE LINE 52
        __M_writer(unicode(username))
        __M_writer(u'"/>\n                <div class="toolParamHelp" style="clear: both;">\n                    Your public name is an identifier that will be used to generate addresses for information\n                    you share publicly. Public names must be at least four characters in length and contain only lower-case\n                    letters, numbers, and the \'-\' character.\n                </div>\n            </div>\n')
        # SOURCE LINE 59
        if trans.app.config.smtp_server:
            # SOURCE LINE 60
            __M_writer(u'                <div class="form-row">\n                    <label>Subscribe to mailing list:</label>\n')
            # SOURCE LINE 62
            if subscribe_checked:
                # SOURCE LINE 63
                __M_writer(u'                        ')
                subscribe_check_box.checked = True 
                
                __M_writer(u'\n')
            # SOURCE LINE 65
            __M_writer(u'                    ')
            __M_writer(unicode(subscribe_check_box.get_html()))
            __M_writer(u'\n                </div>\n')
        # SOURCE LINE 68
        if user_type_fd_id_select_field:
            # SOURCE LINE 69
            __M_writer(u'                <div class="form-row">\n                    <label>User type</label>\n                    ')
            # SOURCE LINE 71
            __M_writer(unicode(user_type_fd_id_select_field.get_html()))
            __M_writer(u'\n                </div>\n')
        # SOURCE LINE 74
        if user_type_form_definition:
            # SOURCE LINE 75
            for field in widgets:
                # SOURCE LINE 76
                __M_writer(u'                    <div class="form-row">\n                        <label>')
                # SOURCE LINE 77
                __M_writer(unicode(field['label']))
                __M_writer(u'</label>\n                        ')
                # SOURCE LINE 78
                __M_writer(unicode(field['widget'].get_html()))
                __M_writer(u'\n                        <div class="toolParamHelp" style="clear: both;">\n                            ')
                # SOURCE LINE 80
                __M_writer(unicode(field['helptext']))
                __M_writer(u'\n                        </div>\n                        <div style="clear: both"></div>\n                    </div>\n')
            # SOURCE LINE 85
            if not user_type_fd_id_select_field:
                # SOURCE LINE 86
                __M_writer(u'                    <input type="hidden" name="user_type_fd_id" value="')
                __M_writer(unicode(trans.security.encode_id( user_type_form_definition.id )))
                __M_writer(u'"/>\n')
        # SOURCE LINE 89
        __M_writer(u'            <div class="form-row">\n                <input type="submit" name="create_user_button" value="Submit"/>\n            </div>\n        </form>\n    </div>\n\n')
        return ''
    finally:
        context.caller_stack._pop_frame()
 def create_role(self, trans, **kwd):
     params = util.Params(kwd)
     message = util.restore_text(params.get('message', ''))
     status = params.get('status', 'done')
     name = util.restore_text(params.get('name', ''))
     description = util.restore_text(params.get('description', ''))
     in_users = util.listify(params.get('in_users', []))
     out_users = util.listify(params.get('out_users', []))
     in_groups = util.listify(params.get('in_groups', []))
     out_groups = util.listify(params.get('out_groups', []))
     create_group_for_role = params.get('create_group_for_role', '')
     create_group_for_role_checked = CheckboxField.is_checked(
         create_group_for_role)
     ok = True
     if params.get('create_role_button', False):
         if not name or not description:
             message = "Enter a valid name and a description."
             status = 'error'
             ok = False
         elif trans.sa_session.query(trans.app.model.Role).filter(
                 trans.app.model.Role.table.c.name == name).first():
             message = "Role names must be unique and a role with that name already exists, so choose another name."
             status = 'error'
             ok = False
         else:
             # Create the role
             role, num_in_groups = trans.app.security_agent.create_role(
                 name,
                 description,
                 in_users,
                 in_groups,
                 create_group_for_role=create_group_for_role_checked)
             message = "Role '%s' has been created with %d associated users and %d associated groups.  " \
                 % (role.name, len(in_users), num_in_groups)
             if create_group_for_role_checked:
                 message += 'One of the groups associated with this role is the newly created group with the same name.'
             trans.response.send_redirect(
                 web.url_for(controller='admin',
                             action='roles',
                             message=util.sanitize_text(message),
                             status='done'))
     if ok:
         for user in trans.sa_session.query(trans.app.model.User) \
                                     .filter(trans.app.model.User.table.c.deleted == false()) \
                                     .order_by(trans.app.model.User.table.c.email):
             out_users.append((user.id, user.email))
         for group in trans.sa_session.query(trans.app.model.Group) \
                                      .filter(trans.app.model.Group.table.c.deleted == false()) \
                                      .order_by(trans.app.model.Group.table.c.name):
             out_groups.append((group.id, group.name))
     return trans.fill_template(
         '/webapps/tool_shed/admin/dataset_security/role/role_create.mako',
         name=name,
         description=description,
         in_users=in_users,
         out_users=out_users,
         in_groups=in_groups,
         out_groups=out_groups,
         create_group_for_role_checked=create_group_for_role_checked,
         message=message,
         status=status)
 def create_group(self, trans, **kwd):
     params = util.Params(kwd)
     message = util.restore_text(params.get('message', ''))
     status = params.get('status', 'done')
     name = util.restore_text(params.get('name', ''))
     in_users = util.listify(params.get('in_users', []))
     out_users = util.listify(params.get('out_users', []))
     in_roles = util.listify(params.get('in_roles', []))
     out_roles = util.listify(params.get('out_roles', []))
     create_role_for_group = params.get('create_role_for_group', '')
     create_role_for_group_checked = CheckboxField.is_checked(
         create_role_for_group)
     ok = True
     if params.get('create_group_button', False):
         if not name:
             message = "Enter a valid name."
             status = 'error'
             ok = False
         elif trans.sa_session.query(trans.app.model.Group).filter(
                 trans.app.model.Group.table.c.name == name).first():
             message = "Group names must be unique and a group with that name already exists, so choose another name."
             status = 'error'
             ok = False
         else:
             # Create the group
             group = trans.app.model.Group(name=name)
             trans.sa_session.add(group)
             trans.sa_session.flush()
             # Create the UserRoleAssociations
             for user in [
                     trans.sa_session.query(trans.app.model.User).get(x)
                     for x in in_users
             ]:
                 uga = trans.app.model.UserGroupAssociation(user, group)
                 trans.sa_session.add(uga)
             # Create the GroupRoleAssociations
             for role in [
                     trans.sa_session.query(trans.app.model.Role).get(x)
                     for x in in_roles
             ]:
                 gra = trans.app.model.GroupRoleAssociation(group, role)
                 trans.sa_session.add(gra)
             if create_role_for_group_checked:
                 # Create the role
                 role = trans.app.model.Role(
                     name=name, description='Role for group %s' % name)
                 trans.sa_session.add(role)
                 # Associate the role with the group
                 gra = trans.model.GroupRoleAssociation(group, role)
                 trans.sa_session.add(gra)
                 num_in_roles = len(in_roles) + 1
             else:
                 num_in_roles = len(in_roles)
             trans.sa_session.flush()
             message = "Group '%s' has been created with %d associated users and %d associated roles.  " \
                 % (group.name, len(in_users), num_in_roles)
             if create_role_for_group_checked:
                 message += 'One of the roles associated with this group is the newly created role with the same name.'
             trans.response.send_redirect(
                 web.url_for(controller='admin',
                             action='groups',
                             message=util.sanitize_text(message),
                             status='done'))
     if ok:
         for user in trans.sa_session.query(trans.app.model.User) \
                                     .filter(trans.app.model.User.table.c.deleted == false()) \
                                     .order_by(trans.app.model.User.table.c.email):
             out_users.append((user.id, user.email))
         for role in trans.sa_session.query(trans.app.model.Role) \
                                     .filter(trans.app.model.Role.table.c.deleted == false()) \
                                     .order_by(trans.app.model.Role.table.c.name):
             out_roles.append((role.id, role.name))
     return trans.fill_template(
         '/webapps/tool_shed/admin/dataset_security/group/group_create.mako',
         name=name,
         in_users=in_users,
         out_users=out_users,
         in_roles=in_roles,
         out_roles=out_roles,
         create_role_for_group_checked=create_role_for_group_checked,
         message=message,
         status=status)
Beispiel #13
0
 def create_group(self, trans, **kwd):
     params = util.Params(kwd)
     message = util.restore_text(params.get('message', ''))
     status = params.get('status', 'done')
     name = util.restore_text(params.get('name', ''))
     in_users = util.listify(params.get('in_users', []))
     out_users = util.listify(params.get('out_users', []))
     in_roles = util.listify(params.get('in_roles', []))
     out_roles = util.listify(params.get('out_roles', []))
     create_role_for_group = params.get('create_role_for_group', '')
     create_role_for_group_checked = CheckboxField.is_checked(create_role_for_group)
     ok = True
     if params.get('create_group_button', False):
         if not name:
             message = "Enter a valid name."
             status = 'error'
             ok = False
         elif trans.sa_session.query(trans.app.model.Group).filter(trans.app.model.Group.table.c.name == name).first():
             message = "Group names must be unique and a group with that name already exists, so choose another name."
             status = 'error'
             ok = False
         else:
             # Create the group
             group = trans.app.model.Group(name=name)
             trans.sa_session.add(group)
             trans.sa_session.flush()
             # Create the UserRoleAssociations
             for user in [trans.sa_session.query(trans.app.model.User).get(x) for x in in_users]:
                 uga = trans.app.model.UserGroupAssociation(user, group)
                 trans.sa_session.add(uga)
             # Create the GroupRoleAssociations
             for role in [trans.sa_session.query(trans.app.model.Role).get(x) for x in in_roles]:
                 gra = trans.app.model.GroupRoleAssociation(group, role)
                 trans.sa_session.add(gra)
             if create_role_for_group_checked:
                 # Create the role
                 role = trans.app.model.Role(name=name, description='Role for group %s' % name)
                 trans.sa_session.add(role)
                 # Associate the role with the group
                 gra = trans.model.GroupRoleAssociation(group, role)
                 trans.sa_session.add(gra)
                 num_in_roles = len(in_roles) + 1
             else:
                 num_in_roles = len(in_roles)
             trans.sa_session.flush()
             message = "Group '%s' has been created with %d associated users and %d associated roles.  " \
                 % (group.name, len(in_users), num_in_roles)
             if create_role_for_group_checked:
                 message += 'One of the roles associated with this group is the newly created role with the same name.'
             trans.response.send_redirect(web.url_for(controller='admin',
                                                      action='groups',
                                                      message=util.sanitize_text(message),
                                                      status='done'))
     if ok:
         for user in trans.sa_session.query(trans.app.model.User) \
                                     .filter(trans.app.model.User.table.c.deleted == false()) \
                                     .order_by(trans.app.model.User.table.c.email):
             out_users.append((user.id, user.email))
         for role in trans.sa_session.query(trans.app.model.Role) \
                                     .filter(trans.app.model.Role.table.c.deleted == false()) \
                                     .order_by(trans.app.model.Role.table.c.name):
             out_roles.append((role.id, role.name))
     return trans.fill_template('/webapps/tool_shed/admin/dataset_security/group/group_create.mako',
                                name=name,
                                in_users=in_users,
                                out_users=out_users,
                                in_roles=in_roles,
                                out_roles=out_roles,
                                create_role_for_group_checked=create_role_for_group_checked,
                                message=message,
                                status=status)