|
|
@@ -1218,7 +1218,42 @@ def link_event_tiers(request): |
|
|
|
return HTTPFound(location=request.route_url('edit_event', sep='/', |
|
|
|
year=str(year), intervention=intervention, event_id=str(TargetEvent.uid), _anchor="Tiers")) |
|
|
|
|
|
|
|
@view_config(route_name='delete_link') |
|
|
|
@view_config(route_name='delete_link_u') |
|
|
|
def delete_link_event_user(request): |
|
|
|
""" Create user if not exist, add it to current event """ |
|
|
|
if request.user is None: |
|
|
|
# Don't answer to users that aren't logged |
|
|
|
raise HTTPForbidden(u'Vous devez vous identifier pour obtenir une réponse.') |
|
|
|
year = int(request.matchdict.get('year', -1)) |
|
|
|
intervention = request.matchdict.get('intervention', None) |
|
|
|
|
|
|
|
TargetEvent = Event.by_id( request.params.get('eid') ) |
|
|
|
Exist = User.by_id( request.params.get('uid') ) |
|
|
|
if not Exist: |
|
|
|
request.session.flash(('error',u"Une erreur s'est produite lors de votre suppression !")) |
|
|
|
return HTTPFound(location=request.route_url('edit_event', sep='/', |
|
|
|
year=str(year), intervention=intervention, event_id=str(TargetEvent.uid))) |
|
|
|
else: |
|
|
|
TargetUser = Exist |
|
|
|
|
|
|
|
Matching = DBSession.query(User_Event)\ |
|
|
|
.filter(User_Event.year_uid==year)\ |
|
|
|
.filter(User_Event.user_uid==TargetUser.uid)\ |
|
|
|
.filter(User_Event.event_uid==TargetEvent.uid)\ |
|
|
|
.all() |
|
|
|
|
|
|
|
if len(Matching)==0: |
|
|
|
request.session.flash(('error',u"Une erreur s'est produite lors de la suppression !")) |
|
|
|
else: |
|
|
|
for item in Matching: |
|
|
|
DBSession.delete(item) |
|
|
|
|
|
|
|
return HTTPFound(location=request.route_url('edit_event', sep='/', |
|
|
|
year=str(year), intervention=intervention, event_id=str(TargetEvent.uid), _anchor="Tiers")) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@view_config(route_name='delete_link_t') |
|
|
|
def delete_link_event_tiers(request): |
|
|
|
""" Create user if not exist, add it to current event """ |
|
|
|
if request.user is None: |
|
|
|