allura
修訂 | c9959fbb0cb22f0a14ac38bc34f8448eef5a5795 (tree) |
---|---|
時間 | 2012-07-04 16:54:40 |
作者 | Yuriy <yuriyarhipovua@yand...> |
Commiter | Yuriy |
[#4449] Ticket #94 pep8
@@ -108,56 +108,52 @@ class SiteAdminController(object): | ||
108 | 108 | log.info(data['token_list']) |
109 | 109 | return data |
110 | 110 | |
111 | - def check_artifact(self,artifact,url,appconf,user,project): | |
111 | + def check_artifact(self, artifact, url, appconf, user, project): | |
112 | 112 | for ar in artifact.__subclasses__(): |
113 | 113 | for i in ar.query.find({"app_config_id": appconf._id}).all(): |
114 | 114 | if i.url() == urlparse(url).path: |
115 | - M.Mailbox.subscribe(user_id=user._id, | |
115 | + M.Mailbox.subscribe( | |
116 | + user_id=user._id, | |
116 | 117 | app_config_id=appconf._id, |
117 | 118 | project_id=project._id, |
118 | 119 | artifact=i) |
119 | 120 | return |
120 | - self.check_artifact(ar,url,appconf,user,project) | |
121 | + self.check_artifact(ar, url, appconf, user, project) | |
121 | 122 | |
122 | 123 | def subscribe_artifact(self, url, user): |
123 | 124 | artifact_url = urlparse(url).path[1:-1].split("/") |
124 | - log.error(artifact_url) | |
125 | - neighborhood = M.Neighborhood.query.find({"url_prefix": "/" + artifact_url[0] + "/"}).first() | |
125 | + neighborhood = M.Neighborhood.query.find({ | |
126 | + "url_prefix": "/" + artifact_url[0] + "/"}).first() | |
127 | + | |
126 | 128 | if artifact_url[0] == "u": |
127 | - project = M.Project.query.find({"shortname": artifact_url[0]+"/"+artifact_url[1],"neighborhood_id": neighborhood._id}).first() | |
129 | + project = M.Project.query.find({ | |
130 | + "shortname": artifact_url[0] + "/" + artifact_url[1], | |
131 | + "neighborhood_id": neighborhood._id}).first() | |
128 | 132 | else: |
129 | - project = M.Project.query.find({"shortname": artifact_url[1],"neighborhood_id": neighborhood._id}).first() | |
130 | - | |
131 | - log.error("project id:") | |
132 | - log.error(project._id) | |
133 | - for a in M.AppConfig.query.find().all(): | |
134 | - log.error(a.options.mount_point) | |
135 | - log.error(a.project_id) | |
133 | + project = M.Project.query.find({ | |
134 | + "shortname": artifact_url[1], | |
135 | + "neighborhood_id": neighborhood._id}).first() | |
136 | 136 | |
137 | 137 | appconf = M.AppConfig.query.find({ |
138 | 138 | "options.mount_point": artifact_url[2], |
139 | 139 | "project_id": project._id}).first() |
140 | - log.error(appconf._id) | |
141 | - log.error(appconf.url()) | |
142 | - if appconf.url()==urlparse(url).path: | |
140 | + if appconf.url() == urlparse(url).path: | |
143 | 141 | log.error("if appconf") |
144 | - M.Mailbox.subscribe(user_id=user._id, | |
142 | + M.Mailbox.subscribe( | |
143 | + user_id=user._id, | |
145 | 144 | app_config_id=appconf._id, |
146 | 145 | project_id=project._id) |
147 | 146 | return |
148 | 147 | |
149 | 148 | for art in M.Artifact.__subclasses__(): |
150 | - self.check_artifact(art,url,appconf,user,project) | |
149 | + self.check_artifact(art, url, appconf, user, project) | |
151 | 150 | |
152 | 151 | @expose('jinja:allura:templates/site_admin_add_subscribers.html') |
153 | 152 | def add_subscribers(self, **data): |
154 | - log.error("!!!!!!!!!!!!!!!!!!!!!!!!!!!") | |
155 | 153 | if request.method == 'POST': |
156 | - log.error("POST") | |
157 | 154 | url = data['artifact_url'] |
158 | 155 | user = M.User.by_username(data['for_user']) |
159 | 156 | if user is None: |
160 | - log.error("user none") | |
161 | 157 | flash('Invalid login') |
162 | 158 | else: |
163 | 159 | self.subscribe_artifact(url, user) |
@@ -2,6 +2,8 @@ from allura.tests import TestController | ||
2 | 2 | from allura.tests import decorators as td |
3 | 3 | from allura.model.notification import Mailbox |
4 | 4 | from allura import model as M |
5 | + | |
6 | + | |
5 | 7 | class TestSubscriber(TestController): |
6 | 8 | |
7 | 9 | @td.with_user_project('test-admin') |
@@ -16,10 +18,10 @@ class TestSubscriber(TestController): | ||
16 | 18 | assert '[test:wiki] test-admin created page Home' in response |
17 | 19 | |
18 | 20 | i = Mailbox.query.find().count() |
19 | - self.app.post("/nf/admin/add_subscribers",params=dict(for_user="root",artifact_url="http://localhost:8080/u/test-admin/wiki/Home/")) | |
20 | - | |
21 | - | |
22 | - | |
23 | - assert 1 == Mailbox.query.find(dict(user_id=M.User.by_username("root")._id,artifact_url="/u/test-admin/wiki/Home/")).count() | |
24 | - | |
21 | + self.app.post("/nf/admin/add_subscribers", params=dict( | |
22 | + for_user="root", | |
23 | + artifact_url="http://localhost:8080/u/test-admin/wiki/Home/")) | |
25 | 24 | |
25 | + assert 1 == Mailbox.query.find(dict( | |
26 | + user_id=M.User.by_username("root")._id, | |
27 | + artifact_url="/u/test-admin/wiki/Home/")).count() |