root/galaxy-central/database/compiled_templates/dataset/security_common.mako.py @ 3

リビジョン 3, 9.0 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1from mako import runtime, filters, cache
2UNDEFINED = runtime.UNDEFINED
3__M_dict_builtin = dict
4__M_locals_builtin = locals
5_magic_number = 5
6_modified_time = 1287725818.3254099
7_template_filename=u'templates/dataset/security_common.mako'
8_template_uri=u'/dataset/security_common.mako'
9_template_cache=cache.Cache(__name__, _modified_time)
10_source_encoding=None
11_exports = ['render_permission_form', 'render_select']
12
13
14def render_body(context,**pageargs):
15    context.caller_stack._push_frame()
16    try:
17        __M_locals = __M_dict_builtin(pageargs=pageargs)
18        __M_writer = context.writer()
19        # SOURCE LINE 37
20        __M_writer(u'\n\n')
21        # SOURCE LINE 123
22        __M_writer(u'\n')
23        return ''
24    finally:
25        context.caller_stack._pop_frame()
26
27
28def render_render_permission_form(context,obj,obj_name,form_url,all_roles,do_not_render=[]):
29    context.caller_stack._push_frame()
30    try:
31        trans = context.get('trans', UNDEFINED)
32        def render_select(current_actions,action_key,action,all_roles):
33            return render_render_select(context,current_actions,action_key,action,all_roles)
34        isinstance = context.get('isinstance', UNDEFINED)
35        __M_writer = context.writer()
36        # SOURCE LINE 40
37        __M_writer(u'\n    ')
38        # SOURCE LINE 41
39
40        if isinstance( obj, trans.app.model.User ):
41            current_actions = obj.default_permissions
42            permitted_actions = trans.app.model.Dataset.permitted_actions.items()
43            obj_str = 'user %s' % obj_name
44            obj_type = 'dataset'
45        elif isinstance( obj, trans.app.model.History ):
46            current_actions = obj.default_permissions
47            permitted_actions = trans.app.model.Dataset.permitted_actions.items()
48            obj_str = 'history %s' % obj_name
49            obj_type = 'dataset'
50        elif isinstance( obj, trans.app.model.Dataset ):
51            current_actions = obj.actions
52            permitted_actions = trans.app.model.Dataset.permitted_actions.items()
53            obj_str = obj_name
54            obj_type = 'dataset'
55        elif isinstance( obj, trans.app.model.LibraryDatasetDatasetAssociation ):
56            current_actions = obj.actions + obj.dataset.actions
57            permitted_actions = trans.app.model.Dataset.permitted_actions.items() + trans.app.model.Library.permitted_actions.items()
58            obj_str = obj_name
59            obj_type = 'dataset'
60        elif isinstance( obj, trans.app.model.Library ):
61            current_actions = obj.actions
62            permitted_actions = trans.app.model.Library.permitted_actions.items()
63            obj_str = 'library %s' % obj_name
64            obj_type = 'library'
65        elif isinstance( obj, trans.app.model.LibraryDataset ):
66            current_actions = obj.actions
67            permitted_actions = trans.app.model.Library.permitted_actions.items()
68            obj_str = 'library dataset %s' % obj_name
69            obj_type = 'library'
70        elif isinstance( obj, trans.app.model.LibraryFolder ):
71            current_actions = obj.actions
72            permitted_actions = trans.app.model.Library.permitted_actions.items()
73            obj_str = 'library folder %s' % obj_name
74            obj_type = 'library'
75        else:
76            current_actions = []
77            permitted_actions = {}.items()
78            obj_str = 'unknown object %s' %obj_name
79            obj_type = ''
80           
81       
82        # SOURCE LINE 82
83        __M_writer(u'\n    <script type="text/javascript">\n        $( document ).ready( function () {\n            $( \'.role_add_button\' ).click( function() {\n                var action = this.id.substring( 0, this.id.lastIndexOf( \'_add_button\' ) )\n                var in_select = \'#\' + action + \'_in_select\';\n                var out_select = \'#\' + action + \'_out_select\';\n                return !$( out_select + \' option:selected\' ).remove().appendTo( in_select );\n            });\n            $( \'.role_remove_button\' ).click( function() {\n                var action = this.id.substring( 0, this.id.lastIndexOf( \'_remove_button\' ) )\n                var in_select = \'#\' + action + \'_in_select\';\n                var out_select = \'#\' + action + \'_out_select\';\n                return !$( in_select + \' option:selected\' ).remove().appendTo( out_select );\n            });\n            $( \'form#edit_role_associations\' ).submit( function() {\n                $( \'.in_select option\' ).each(function( i ) {\n                    $( this ).attr( "selected", "selected" );\n                });\n            });\n        });\n    </script>\n    <div class="toolForm">\n        <div class="toolFormTitle">Manage ')
84        # SOURCE LINE 105
85        __M_writer(unicode(obj_type))
86        __M_writer(u' permissions on ')
87        __M_writer(unicode(obj_str))
88        __M_writer(u'</div>\n        <div class="toolFormBody">\n            <form name="edit_role_associations" id="edit_role_associations" action="')
89        # SOURCE LINE 107
90        __M_writer(unicode(form_url))
91        __M_writer(u'" method="post">\n                <div class="form-row"></div>\n')
92        # SOURCE LINE 109
93        for k, v in permitted_actions:
94            # SOURCE LINE 110
95            if k not in do_not_render:
96                # SOURCE LINE 111
97                __M_writer(u'                        <div class="form-row">\n                            ')
98                # SOURCE LINE 112
99                __M_writer(unicode(render_select( current_actions, k, v, all_roles )))
100                __M_writer(u'\n                        </div>\n')
101        # SOURCE LINE 116
102        __M_writer(u'                <div class="form-row">\n                    <input type="submit" name="update_roles_button" value="Save"/>\n                </div>\n            </form>\n        </div>\n    </div>\n    <p/>\n')
103        return ''
104    finally:
105        context.caller_stack._pop_frame()
106
107
108def render_render_select(context,current_actions,action_key,action,all_roles):
109    context.caller_stack._push_frame()
110    try:
111        filter = context.get('filter', UNDEFINED)
112        x = context.get('x', UNDEFINED)
113        trans = context.get('trans', UNDEFINED)
114        __M_writer = context.writer()
115        # SOURCE LINE 1
116        __M_writer(u'\n    ')
117        # SOURCE LINE 2
118
119        import sets
120        in_roles = sets.Set()
121        for a in current_actions:
122            if a.action == action.action:
123                in_roles.add( a.role )
124        out_roles = filter( lambda x: x not in in_roles, all_roles )
125           
126       
127        # SOURCE LINE 9
128        __M_writer(u'\n    <p>\n        <b>')
129        # SOURCE LINE 11
130        __M_writer(unicode(action.action))
131        __M_writer(u':</b> ')
132        __M_writer(unicode(action.description))
133        __M_writer(u'\n')
134        # SOURCE LINE 12
135        if action == trans.app.security_agent.permitted_actions.DATASET_ACCESS:
136            # SOURCE LINE 13
137            __M_writer(u'            <br/>\n            NOTE: Users must have every role associated with this dataset in order to access it\n')
138        # SOURCE LINE 16
139        __M_writer(u'    </p>\n    <div style="width: 100%; white-space: nowrap;">\n        <div style="float: left; width: 50%;">\n            Roles associated:<br/>\n            <select name="')
140        # SOURCE LINE 20
141        __M_writer(unicode(action_key))
142        __M_writer(u'_in" id="')
143        __M_writer(unicode(action_key))
144        __M_writer(u'_in_select" class="in_select" style="max-width: 98%; width: 98%; height: 150px; font-size: 100%;" multiple>\n')
145        # SOURCE LINE 21
146        for role in in_roles:
147            # SOURCE LINE 22
148            __M_writer(u'                    <option value="')
149            __M_writer(unicode(role.id))
150            __M_writer(u'">')
151            __M_writer(unicode(role.name))
152            __M_writer(u'</option>\n')
153        # SOURCE LINE 24
154        __M_writer(u'            </select> <br/>\n            <div style="width: 98%; text-align: right"><input type="submit" id="')
155        # SOURCE LINE 25
156        __M_writer(unicode(action_key))
157        __M_writer(u'_remove_button" class="role_remove_button" value=">>"/></div>\n        </div>\n        <div style="width: 50%;">\n            Roles not associated:<br/>\n            <select name="')
158        # SOURCE LINE 29
159        __M_writer(unicode(action_key))
160        __M_writer(u'_out" id="')
161        __M_writer(unicode(action_key))
162        __M_writer(u'_out_select" style="max-width: 98%; width: 98%; height: 150px; font-size: 100%;" multiple>\n')
163        # SOURCE LINE 30
164        for role in out_roles:
165            # SOURCE LINE 31
166            __M_writer(u'                    <option value="')
167            __M_writer(unicode(role.id))
168            __M_writer(u'">')
169            __M_writer(unicode(role.name))
170            __M_writer(u'</option>\n')
171        # SOURCE LINE 33
172        __M_writer(u'            </select> <br/>\n            <input type="submit" id="')
173        # SOURCE LINE 34
174        __M_writer(unicode(action_key))
175        __M_writer(u'_add_button" class="role_add_button" value="<<"/>\n        </div>\n    </div>\n')
176        return ''
177    finally:
178        context.caller_stack._pop_frame()
179
180
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。