allura
Revision | 4d0ad863410986c46e2f31a804848ea40a42722a (tree) |
---|---|
Zeit | 2012-07-10 17:30:50 |
Autor | Igor Bondarenko <jetmind2@gmai...> |
Commiter | Igor Bondarenko |
[#4449] ticket:104 Fix invalid data handling.
@@ -126,7 +126,7 @@ class SiteAdminController(object): | ||
126 | 126 | user_id=user._id, |
127 | 127 | app_config_id=appconf._id, |
128 | 128 | project_id=project._id) |
129 | - return | |
129 | + return True | |
130 | 130 | |
131 | 131 | classes = set() |
132 | 132 | for depth, cls in dfs(M.Artifact, build_model_inheritance_graph()): |
@@ -139,21 +139,28 @@ class SiteAdminController(object): | ||
139 | 139 | app_config_id=appconf._id, |
140 | 140 | project_id=project._id, |
141 | 141 | artifact=artifact) |
142 | - return | |
142 | + return True | |
143 | + return False | |
143 | 144 | |
144 | 145 | @expose('jinja:allura:templates/site_admin_add_subscribers.html') |
145 | 146 | def add_subscribers(self, **data): |
146 | 147 | if request.method == 'POST': |
147 | 148 | url = data['artifact_url'] |
148 | 149 | user = M.User.by_username(data['for_user']) |
149 | - if user is None: | |
150 | + if not user or user == M.User.anonymous(): | |
150 | 151 | flash('Invalid login', 'error') |
151 | 152 | return data |
153 | + | |
152 | 154 | try: |
153 | - self.subscribe_artifact(url, user) | |
155 | + ok = self.subscribe_artifact(url, user) | |
154 | 156 | except: |
155 | 157 | log.warn("Can't subscribe to artifact", exc_info=True) |
158 | + ok = False | |
159 | + | |
160 | + if ok: | |
161 | + flash('User successfully subscribed to the artifact') | |
162 | + return {} | |
163 | + else: | |
156 | 164 | flash('Artifact not found', 'error') |
157 | - return data | |
158 | - flash('User successfully subscribed to the artifact') | |
159 | - return {} | |
165 | + | |
166 | + return data |