Move some variables out of the controller, fix templates a bit.
This commit is contained in:
parent
5db6c6db96
commit
b784ee761f
4 changed files with 15 additions and 9 deletions
|
@ -126,7 +126,7 @@ class Group(controllers.Controller):
|
|||
turbogears.redirect('/group/list')
|
||||
return dict()
|
||||
else:
|
||||
return dict(person=person, group=group)
|
||||
return dict(group=group)
|
||||
|
||||
@identity.require(turbogears.identity.not_anonymous())
|
||||
@expose(template="fas.templates.group.new")
|
||||
|
@ -243,12 +243,13 @@ class Group(controllers.Controller):
|
|||
|
||||
re_search = re.sub(r'\*', r'%', search).lower()
|
||||
groups = Groups.query.filter(Groups.name.like(re_search)).order_by('name')
|
||||
if groups.count() <= 0:
|
||||
groups = filter(lambda group: canViewGroup(person, group), groups)
|
||||
if len(groups) <= 0:
|
||||
turbogears.flash(_("No Groups found matching '%s'") % search)
|
||||
groups = {}
|
||||
if self.jsonRequest():
|
||||
return ({'groups': groups})
|
||||
return dict(groups=groups, search=search, person=person)
|
||||
return dict(groups=groups, search=search)
|
||||
|
||||
@identity.require(turbogears.identity.not_anonymous())
|
||||
@validate(validators=usernameGroupnameExists())
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
Model for the Fedora Account System
|
||||
'''
|
||||
from datetime import datetime
|
||||
from time import time
|
||||
from turbogears.database import metadata, mapper, get_engine
|
||||
# import some basic SQLAlchemy classes for declaring the data model
|
||||
# (see http://www.sqlalchemy.org/docs/04/ormtutorial.html)
|
||||
|
@ -166,12 +167,12 @@ class People(SABase):
|
|||
|
||||
def sponsor(cls, group, requester):
|
||||
# If we want to do logging, this might be the place.
|
||||
# TODO: Find out how to log timestamp
|
||||
if not group in cls.memberships:
|
||||
raise '%s not a member of %s' % (group.name, cls.memberships)
|
||||
role = PersonRoles.query.filter_by(member=cls, group=group).one()
|
||||
role.role_status = 'approved'
|
||||
role.sponsor_id = requester.id
|
||||
role.approval = time()
|
||||
|
||||
def remove(cls, group, requester):
|
||||
role = PersonRoles.query.filter_by(member=cls, group=group).one()
|
||||
|
|
|
@ -7,8 +7,10 @@
|
|||
<title>${_('Groups List')}</title>
|
||||
</head>
|
||||
<body>
|
||||
<?python from fas import auth ?>
|
||||
<?python from fas.model import Groups ?>
|
||||
<?python
|
||||
from fas.model import Groups, People
|
||||
person = People.by_username(tg.identity.user.username)
|
||||
?>
|
||||
<span py:if="Groups.by_name('accounts') in person.approved_memberships">
|
||||
<h2>Create New Group</h2>
|
||||
<a href='new'>Create Group</a>
|
||||
|
@ -35,7 +37,6 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
<tr py:for="group in groups">
|
||||
<div py:if="auth.canViewGroup(person, group)" py:strip="">
|
||||
<td><a href="${tg.url('/group/view/%s' % group.name)}">${group.name}</a></td>
|
||||
<td>${ group.display_name }</td>
|
||||
<td>
|
||||
|
@ -45,7 +46,6 @@
|
|||
</a>
|
||||
<a py:if="group not in person.memberships" href="${tg.url('/group/apply/%s/%s' % (group.name, person.username))}"><span>${_('Apply')}</span></a>
|
||||
</td>
|
||||
</div>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
@ -7,7 +7,11 @@
|
|||
<title>${_('Edit Group')}</title>
|
||||
</head>
|
||||
<body>
|
||||
<?python from fas import auth ?>
|
||||
<?python
|
||||
from fas import auth
|
||||
from fas.model import People
|
||||
person = People.by_username(tg.identity.user.username)
|
||||
?>
|
||||
<h2>${group.display_name} (${group.name})</h2>
|
||||
<h3>
|
||||
${_('My Status:')}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue