• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

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

allura


Commit MetaInfo

修訂c9959fbb0cb22f0a14ac38bc34f8448eef5a5795 (tree)
時間2012-07-04 16:54:40
作者Yuriy <yuriyarhipovua@yand...>
CommiterYuriy

Log Message

[#4449] Ticket #94 pep8

Change Summary

差異

--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -108,56 +108,52 @@ class SiteAdminController(object):
108108 log.info(data['token_list'])
109109 return data
110110
111- def check_artifact(self,artifact,url,appconf,user,project):
111+ def check_artifact(self, artifact, url, appconf, user, project):
112112 for ar in artifact.__subclasses__():
113113 for i in ar.query.find({"app_config_id": appconf._id}).all():
114114 if i.url() == urlparse(url).path:
115- M.Mailbox.subscribe(user_id=user._id,
115+ M.Mailbox.subscribe(
116+ user_id=user._id,
116117 app_config_id=appconf._id,
117118 project_id=project._id,
118119 artifact=i)
119120 return
120- self.check_artifact(ar,url,appconf,user,project)
121+ self.check_artifact(ar, url, appconf, user, project)
121122
122123 def subscribe_artifact(self, url, user):
123124 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+
126128 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()
128132 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()
136136
137137 appconf = M.AppConfig.query.find({
138138 "options.mount_point": artifact_url[2],
139139 "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:
143141 log.error("if appconf")
144- M.Mailbox.subscribe(user_id=user._id,
142+ M.Mailbox.subscribe(
143+ user_id=user._id,
145144 app_config_id=appconf._id,
146145 project_id=project._id)
147146 return
148147
149148 for art in M.Artifact.__subclasses__():
150- self.check_artifact(art,url,appconf,user,project)
149+ self.check_artifact(art, url, appconf, user, project)
151150
152151 @expose('jinja:allura:templates/site_admin_add_subscribers.html')
153152 def add_subscribers(self, **data):
154- log.error("!!!!!!!!!!!!!!!!!!!!!!!!!!!")
155153 if request.method == 'POST':
156- log.error("POST")
157154 url = data['artifact_url']
158155 user = M.User.by_username(data['for_user'])
159156 if user is None:
160- log.error("user none")
161157 flash('Invalid login')
162158 else:
163159 self.subscribe_artifact(url, user)
--- a/Allura/allura/tests/functional/test_subscriber.py
+++ b/Allura/allura/tests/functional/test_subscriber.py
@@ -2,6 +2,8 @@ from allura.tests import TestController
22 from allura.tests import decorators as td
33 from allura.model.notification import Mailbox
44 from allura import model as M
5+
6+
57 class TestSubscriber(TestController):
68
79 @td.with_user_project('test-admin')
@@ -16,10 +18,10 @@ class TestSubscriber(TestController):
1618 assert '[test:wiki] test-admin created page Home' in response
1719
1820 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/"))
2524
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()