|
@@ 261-279 (lines=19) @@
|
| 258 |
|
print(vendor) |
| 259 |
|
print(vendor_url) |
| 260 |
|
datalayer.new_request(request.user, request_text, vendor, vendor_url) |
| 261 |
|
|
| 262 |
|
request.session.flash('Request added successfully', 'success') |
| 263 |
|
return HTTPFound(location=request.route_url('user_item_request')) |
| 264 |
|
|
| 265 |
|
except ValueError: |
| 266 |
|
request.session.flash('Please include a detailed description of the item.', 'error') |
| 267 |
|
return HTTPFound(location=request.route_url('user_item_request')) |
| 268 |
|
|
| 269 |
|
except: |
| 270 |
|
request.session.flash('Error adding request.', 'error') |
| 271 |
|
return HTTPFound(location=request.route_url('user_item_request')) |
| 272 |
|
|
| 273 |
|
|
| 274 |
|
@view_config(route_name='user_item_request_post_new', |
| 275 |
|
request_method='POST', |
| 276 |
|
permission='user') |
| 277 |
|
def item_request_post_new(request): |
| 278 |
|
try: |
| 279 |
|
item_request = Request.from_id(request.matchdict['id']) |
| 280 |
|
post_text = request.POST['post'] |
| 281 |
|
if post_text.strip() == '': |
| 282 |
|
request.session.flash('Empty comment not saved.', 'error') |
|
@@ 357-368 (lines=12) @@
|
| 354 |
|
try: |
| 355 |
|
pool = Pool.from_id(request.POST['pool-id']) |
| 356 |
|
if pool.owner != request.user.id: |
| 357 |
|
request.session.flash('You do not have permission to view that pool.', 'error') |
| 358 |
|
return HTTPFound(location=request.route_url('user_pools')) |
| 359 |
|
|
| 360 |
|
# Look up the user that is being added to the pool |
| 361 |
|
user = User.from_uniqname(request.POST['uniqname'].strip(), True) |
| 362 |
|
if user == None: |
| 363 |
|
request.session.flash('Could not find that user.', 'error') |
| 364 |
|
return HTTPFound(location=request.route_url('user_pool', pool_id=pool.id)) |
| 365 |
|
|
| 366 |
|
# Can't add yourself |
| 367 |
|
if user.id == pool.owner: |
| 368 |
|
request.session.flash('You cannot add yourself to a pool. By owning the pool you are automatically a part of it.', 'error') |
| 369 |
|
return HTTPFound(location=request.route_url('user_pool', pool_id=pool.id)) |
| 370 |
|
|
| 371 |
|
# Make sure the user isn't already in the pool |