Exemplo n.º 1
0
    def show(self, id):
        group = Groups.get(id)
        if not can_edit(group):
            return redirect_to('/groups')

        if group:
            show_group_fields.update(group.__dict__)

            user_names = get_user_names()
            group_names = get_group_names()

            if len(user_names) > 1000:
                user_names = []

            js = """
            var known_user_names = %(user_names)s;
            var known_group_names = %(group_names)s;

            $(function(){
                $( "#member" ).autocomplete({ source: known_user_names });
                $( "#subgroup" ).autocomplete({ source: known_group_names });
            })
            """ % locals()

            page = Page('show', GroupFiller(id))
            page.js = js
            page.css = """ 
                .ui-menu-item { text-align: left; }
                div.content img.trash { border: none; margin: 0; }
                sdiv.content input { height: 30px; }
                """
            return page
        else:
            return Page(markdown('Groups\n====\nUnknown group'))
Exemplo n.º 2
0
    def show(self, id):     
        group = Groups.get(id)
        if not can_edit(group):
            return redirect_to('/groups')

        if group:
            show_group_fields.update(group.__dict__)

            user_names = get_user_names()
            group_names = get_group_names()

            if len(user_names) > 1000:
                user_names = [];

            js = """
            var known_user_names = %(user_names)s;
            var known_group_names = %(group_names)s;

            $(function(){
                $( "#member" ).autocomplete({ source: known_user_names });
                $( "#subgroup" ).autocomplete({ source: known_group_names });
            })
            """ % locals()

            page = Page('show', GroupFiller(id))
            page.js = js
            page.css = """ 
                .ui-menu-item { text-align: left; }
                div.content img.trash { border: none; margin: 0; }
                sdiv.content input { height: 30px; }
                """
            return page
        else:
            return Page(markdown('Groups\n====\nUnknown group'))
Exemplo n.º 3
0
 def add_member_button(self, group_id, member):
     group = Groups.get(group_id)
     if not (user.is_admin or group.admin in user.groups):
         return redirect_to('/groups')
     if member in get_user_names():
         Groups.get(group_id).add_member(member)
         return redirect_to(url_for('/groups/%s' % group_id))
     else:
         error('unknown username %s' % member)
Exemplo n.º 4
0
 def add_member_button(self, group_id, member):
     group = Groups.get(group_id)
     if not (user.is_admin or group.admin in user.groups):
         return redirect_to("/groups")
     if member in get_user_names():
         Groups.get(group_id).add_member(member)
         return redirect_to(url_for("/groups/%s" % group_id))
     else:
         error("unknown username %s" % member)