• 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

修訂bb1a48e4668569ba5832e041dba0118d8cb42dff (tree)
時間2012-07-02 07:25:53
作者Yuriy <yuriyarhipovua@yand...>
CommiterYuriy

Log Message

[#4449] ticket:94 Subscribe another user to an artifact
pep8

Change Summary

差異

--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -22,12 +22,13 @@ from urlparse import urlparse
2222 from urllib2 import urlopen
2323
2424
25-
2625 log = logging.getLogger(__name__)
2726
27+
2828 class F(object):
2929 add_subscriber_form = AddSubscribtionToUser()
3030
31+
3132 class SiteAdminController(object):
3233
3334 def _check_security(self):
@@ -108,7 +109,9 @@ class SiteAdminController(object):
108109 elif request.method == 'GET':
109110 data = {'expires': datetime.utcnow() + timedelta(days=2)}
110111
111- data['token_list'] = M.ApiTicket.query.find().sort('mod_date', pymongo.DESCENDING).all()
112+ data['token_list'] = M.ApiTicket.query.find().sort(
113+ 'mod_date',
114+ pymongo.DESCENDING).all()
112115 log.info(data['token_list'])
113116 return data
114117
@@ -117,27 +120,30 @@ class SiteAdminController(object):
117120 c.form = F.add_subscriber_form
118121 if request.method == 'POST':
119122 url = data['artifact_url']
120- try :
123+ try:
121124 user_id = M.User.by_username(data['for_user'])._id
122- except :
125+ except:
123126 flash("Invalid login")
124127 return data
125128
126129 artifact_url = urlparse(url).path
127- try :
130+ try:
128131 urlopen(url + "subscribe?subscribe=True")
129- except :
132+ except:
130133 flash("Invalid URL")
131134 return data
132135
133- already_subscribed = M.Mailbox.query.get(user_id = user_id,artifact_url = artifact_url,type = "direct")
136+ already_subscribed = M.Mailbox.query.get(
137+ user_id=user_id,
138+ artifact_url=artifact_url,
139+ type="direct")
134140 if not already_subscribed:
135- subscribe = M.Mailbox.query.find({"user_id":None,"artifact_url":artifact_url,"type" :"direct",}).first()
141+ subscribe = M.Mailbox.query.find({
142+ "user_id": None,
143+ "artifact_url": artifact_url,
144+ "type": "direct", }).first()
136145 if subscribe:
137- subscribe.user_id=user_id
146+ subscribe.user_id = user_id
138147 redirect("/nf/admin/")
139148
140149 return data
141-
142-
143-
--- a/Allura/allura/lib/widgets/subscriptions.py
+++ b/Allura/allura/lib/widgets/subscriptions.py
@@ -50,15 +50,11 @@ class SubscribeForm(ew.SimpleForm):
5050 def from_python(self, value, state):
5151 return value
5252
53+
5354 class AddSubscribtionToUser(ForgeForm):
54- submit_text='Save'
55- style='wide'
55+ submit_text = 'Save'
56+ style = 'wide'
57+
5658 class fields(ew_core.NameList):
5759 for_user = ew.TextField(label='Username')
5860 artifact_url = ew.TextField(label='Url')
59-
60-
61-
62-
63-
64-
--- a/Allura/allura/tests/functional/test_subscriber.py
+++ b/Allura/allura/tests/functional/test_subscriber.py
@@ -1,7 +1,8 @@
11 from allura.tests import TestController
22
3+
34 class TestSubscriber(TestController):
45
56 def test_add_subscriber(self):
67 response = self.app.get('/nf/admin/add_subscribers')
7- assert "<h1>Add Subscribers</h1>" in response
\ No newline at end of file
8+ assert "<h1>Add Subscribers</h1>" in response