Преглед изворни кода

Some fixes for organisation part

handle user removing from an event
master
tr4ck3ur des JM2L пре 9 година
родитељ
комит
8e9dff3a07
5 измењених фајлова са 42 додато и 6 уклоњено
  1. +2
    -1
      jm2l/__init__.py
  2. +1
    -1
      jm2l/helpers.py
  3. +1
    -1
      jm2l/models.py
  4. +2
    -2
      jm2l/templates/edit_event.mako
  5. +36
    -1
      jm2l/views.py

+ 2
- 1
jm2l/__init__.py Прегледај датотеку

@@ -135,8 +135,9 @@ def main(global_config, **settings):
## Events
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('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('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('delete_event', '/MesJM2L/{year:\d+}/{intervention:[\s\w]+}{sep:/*}{event_id:([\w-]+)?}/delete')


+ 1
- 1
jm2l/helpers.py Прегледај датотеку

@@ -132,7 +132,7 @@ class Orga_helpers(DummySejour):

def IsChecked(self, nb):
nb = 2**nb
if self.Sejour:
if self.Sejour and self.Sejour.orga_part:
if self.Sejour.orga_part & nb == nb:
return "checked=\"checked\""
else:


+ 1
- 1
jm2l/models.py Прегледај датотеку

@@ -566,7 +566,7 @@ class Sejour(Base):
repas_allerg = Column(Unicode(100))
repas_contr = Column(Unicode(100))
orga_part = Column(Integer, default=0)
#travel_detail = Column(UnicodeText)
travel_detail = Column(UnicodeText)
created = Column(DateTime, default=datetime.datetime.now)
last_change = Column(DateTime, default=datetime.datetime.now)


+ 2
- 2
jm2l/templates/edit_event.mako Прегледај датотеку

@@ -110,7 +110,7 @@ DicForm = {
% endif

<%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>
</a>
</%def>
@@ -170,7 +170,7 @@ DicForm = {
(${iterv.pseudo})
%endif
% 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>
</a>
%endif


+ 36
- 1
jm2l/views.py Прегледај датотеку

@@ -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:


Loading…
Откажи
Сачувај