@@ -135,8 +135,9 @@ def main(global_config, **settings): | |||||
## Events | ## Events | ||||
config.add_route('event', '/event/{year:\d+}/{event_id:([\w-]+)?}') | config.add_route('event', '/event/{year:\d+}/{event_id:([\w-]+)?}') | ||||
config.add_route('link_event_user', '/MesJM2L/{year:\d+}/{intervention:[\s\w]+}/link_user') | config.add_route('link_event_user', '/MesJM2L/{year:\d+}/{intervention:[\s\w]+}/link_user') | ||||
config.add_route('delete_link_u', '/MesJM2L/{year:\d+}/{intervention:[\s\w]+}/delete_link_user') | |||||
config.add_route('link_event_tiers', '/MesJM2L/{year:\d+}/{intervention:[\s\w]+}/link_tiers') | config.add_route('link_event_tiers', '/MesJM2L/{year:\d+}/{intervention:[\s\w]+}/link_tiers') | ||||
config.add_route('delete_link', '/MesJM2L/{year:\d+}/{intervention:[\s\w]+}/delete_link') | |||||
config.add_route('delete_link_t', '/MesJM2L/{year:\d+}/{intervention:[\s\w]+}/delete_link_tiers') | |||||
config.add_route('edit_event', '/MesJM2L/{year:\d+}/{intervention:[\s\w]+}{sep:/*}{event_id:([\w-]+)?}') | config.add_route('edit_event', '/MesJM2L/{year:\d+}/{intervention:[\s\w]+}{sep:/*}{event_id:([\w-]+)?}') | ||||
config.add_route('delete_event', '/MesJM2L/{year:\d+}/{intervention:[\s\w]+}{sep:/*}{event_id:([\w-]+)?}/delete') | config.add_route('delete_event', '/MesJM2L/{year:\d+}/{intervention:[\s\w]+}{sep:/*}{event_id:([\w-]+)?}/delete') | ||||
@@ -132,7 +132,7 @@ class Orga_helpers(DummySejour): | |||||
def IsChecked(self, nb): | def IsChecked(self, nb): | ||||
nb = 2**nb | nb = 2**nb | ||||
if self.Sejour: | |||||
if self.Sejour and self.Sejour.orga_part: | |||||
if self.Sejour.orga_part & nb == nb: | if self.Sejour.orga_part & nb == nb: | ||||
return "checked=\"checked\"" | return "checked=\"checked\"" | ||||
else: | else: | ||||
@@ -566,7 +566,7 @@ class Sejour(Base): | |||||
repas_allerg = Column(Unicode(100)) | repas_allerg = Column(Unicode(100)) | ||||
repas_contr = Column(Unicode(100)) | repas_contr = Column(Unicode(100)) | ||||
orga_part = Column(Integer, default=0) | orga_part = Column(Integer, default=0) | ||||
#travel_detail = Column(UnicodeText) | |||||
travel_detail = Column(UnicodeText) | |||||
created = Column(DateTime, default=datetime.datetime.now) | created = Column(DateTime, default=datetime.datetime.now) | ||||
last_change = Column(DateTime, default=datetime.datetime.now) | last_change = Column(DateTime, default=datetime.datetime.now) | ||||
@@ -110,7 +110,7 @@ DicForm = { | |||||
% endif | % endif | ||||
<%def name="callback_Del_Summary(Entity)"> \ | <%def name="callback_Del_Summary(Entity)"> \ | ||||
<a class="btn btn-danger btn-mini pull-right" type="button" href="delete_link?tid=${Entity.uid}&uid=${event.uid}"> | |||||
<a class="btn btn-danger btn-mini pull-right" type="button" href="delete_link_tiers?tid=${Entity.uid}&uid=${event.uid}"> | |||||
<i class="icon-remove icon-white"></i> | <i class="icon-remove icon-white"></i> | ||||
</a> | </a> | ||||
</%def> | </%def> | ||||
@@ -170,7 +170,7 @@ DicForm = { | |||||
(${iterv.pseudo}) | (${iterv.pseudo}) | ||||
%endif | %endif | ||||
% if iterv!=request.user: | % if iterv!=request.user: | ||||
<a class="btn btn-danger btn-mini" type="button" href="delete_interv?uid=${iterv.uid}&eid=${event.uid}"> | |||||
<a class="btn btn-danger btn-mini" type="button" href="delete_link_user?uid=${iterv.uid}&eid=${event.uid}"> | |||||
<i class="icon-remove icon-white"></i> | <i class="icon-remove icon-white"></i> | ||||
</a> | </a> | ||||
%endif | %endif | ||||
@@ -1218,7 +1218,42 @@ def link_event_tiers(request): | |||||
return HTTPFound(location=request.route_url('edit_event', sep='/', | return HTTPFound(location=request.route_url('edit_event', sep='/', | ||||
year=str(year), intervention=intervention, event_id=str(TargetEvent.uid), _anchor="Tiers")) | 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): | def delete_link_event_tiers(request): | ||||
""" Create user if not exist, add it to current event """ | """ Create user if not exist, add it to current event """ | ||||
if request.user is None: | if request.user is None: | ||||