• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

allura


Commit MetaInfo

Révision7d983c45fc37bf55b47172023c681dbf081caa88 (tree)
l'heure2012-07-17 19:09:48
AuteurIgor Bondarenko <jetmind2@gmai...>
CommiterIgor Bondarenko

Message de Log

[#4528] ticket:120 omit deleted projects in my_projects plus test

Change Summary

Modification

--- a/Allura/allura/ext/user_profile/templates/user_index.html
+++ b/Allura/allura/ext/user_profile/templates/user_index.html
@@ -25,7 +25,7 @@
2525 <div class="project-list grid-18">
2626 <b>Projects</b>
2727 <ul>
28- {% for p in user.my_projects(exclude_deleted=True) %}
28+ {% for p in user.my_projects() %}
2929 {% if h.has_access(p, 'read')() %}
3030 <li>
3131 <a class="project-name" href="{{p.url()}}">{{p.name}}</a>
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -429,17 +429,16 @@ class User(MappedClass, ActivityNode, ActivityObject):
429429 def script_name(self):
430430 return '/u/' + self.username + '/'
431431
432- def my_projects(self, exclude_deleted=False):
432+ def my_projects(self):
433433 '''Find the projects for which this user has a named role.'''
434434 reaching_role_ids = g.credentials.user_roles(user_id=self._id).reaching_ids_set
435435 reaching_roles = [ ProjectRole.query.get(_id=i) for i in reaching_role_ids ]
436- named_roles = [ r for r in reaching_roles if r.name ]
436+ named_roles = [ r for r in reaching_roles
437+ if r.name and not r.project.deleted ]
437438 seen_project_ids = set()
438439 for r in named_roles:
439440 if r.project_id in seen_project_ids: continue
440441 seen_project_ids.add(r.project_id)
441- if exclude_deleted and r.project.deleted:
442- continue
443442 yield r.project
444443
445444 def project_role(self, project=None):
--- a/Allura/allura/tests/model/test_auth.py
+++ b/Allura/allura/tests/model/test_auth.py
@@ -64,6 +64,10 @@ def test_user():
6464 assert c.user.url() .endswith('/u/test-admin/')
6565 assert c.user.script_name .endswith('/u/test-admin/')
6666 assert set(p.shortname for p in c.user.my_projects()) == set(['test', 'test2', 'u/test-admin', 'adobe-1', '--init--'])
67+ # delete one of projects and make sure it's don't appear in my_projects()
68+ p = M.Project.query.get(shortname='test2')
69+ p.deleted = True
70+ assert set(p.shortname for p in c.user.my_projects()) == set(['test', 'u/test-admin', 'adobe-1', '--init--'])
6771 assert M.User.anonymous().project_role().name == '*anonymous'
6872 u = M.User.register(dict(
6973 username='nosetest-user'))