Project

General

Profile

« Previous | Next » 

Revision 1df3d699

Added by Serghei Mihai over 10 years ago

agenda: deleting cookies properly: by name and path. Removing them unuseful places

Closes #3636

View differences:

calebasse/agenda/views.py
69 69
        return context
70 70

  
71 71

  
72
class AgendaServiceActivityView(TemplateView):
72
class AgendaServiceActivityView(TemplateView, cbv.ServiceViewMixin):
73 73
    template_name = 'agenda/service-activity.html'
74
    cookies_to_clear = ['agenda-worker-tabs']
74 75

  
75 76
    def get_context_data(self, **kwargs):
76 77
        context = super(AgendaServiceActivityView, self).get_context_data(**kwargs)
......
290 291

  
291 292
class AgendaServiceActValidationView(TemplateView):
292 293
    template_name = 'agenda/act-validation.html'
294
    cookies_to_clear = ['agenda-worker-tabs']
293 295

  
294 296
    def acts_of_the_day(self):
295 297
        acts = list(Act.objects \
......
419 421

  
420 422
class AgendasTherapeutesView(AgendaHomepageView):
421 423
    template_name = 'agenda/agendas-therapeutes.html'
424
    cookies_to_clear = ['agenda-worker-tabs']
422 425

  
423 426
    def get_context_data(self, **kwargs):
424 427
        context = super(AgendasTherapeutesView, self).get_context_data(**kwargs)
......
504 507
class RessourcesView(TemplateView):
505 508

  
506 509
    template_name = 'agenda/ressources.html'
510
    cookies_to_clear = []
507 511

  
508 512
    def get_context_data(self, **kwargs):
509 513
        context = super(RessourcesView, self).get_context_data(**kwargs)
......
622 626
class PeriodicEventsView(cbv.ListView):
623 627
    model = EventWithAct
624 628
    template_name = 'agenda/periodic-events.html'
629
    cookies_to_clear = ['agenda-worker-tabs']
625 630

  
626 631
    def dispatch(self, request, *args, **kwargs):
627 632
        if 'worker_id' in kwargs:
calebasse/cbv.py
32 32
    popup = False
33 33
    cookies_to_clear = [ 'agenda-worker-tabs', 'active-resource-agenda' ]
34 34

  
35
    def clear_cookies(self, response):
35
    def clear_cookies(self, response, path):
36 36
        for cookie in self.cookies_to_clear:
37
            response.delete_cookie(cookie)
37
            response.delete_cookie(cookie,
38
                                   path = '/'.join(path.split('/')[:3])
39
                                   )
38 40

  
39 41
    def dispatch(self, request, **kwargs):
40 42
        self.popup = request.GET.get('popup')
......
50 52
        if self.service:
51 53
            result.set_cookie(HOME_SERVICE_COOKIE, self.service.slug,
52 54
                    max_age=3600*24*365, httponly=True)
53
        self.clear_cookies(result)
55
        self.clear_cookies(result, request.path)
54 56
        return result
55 57

  
56 58
    def get_context_data(self, **kwargs):
calebasse/static/js/calebasse.agenda.js
370 370
          $('a.tab').click(function() {
371 371
              $.cookie('active-worker-agenda', $(this).data('id'),  { path: COOKIE_PATH });
372 372
          });
373

  
374
          if ($.cookie('agenda-worker-tabs')) {
375
              $.each($.cookie('agenda-worker-tabs'), function (i, worker_selector) {
376
                  toggle_worker('#' + worker_selector);
377
              });
378
              if ($.cookie('active-worker-agenda'))
379
              {
380
                  var target = $('#link-tab-worker' + $.cookie('active-worker-agenda'));
381
                  if (target.is(':visible')) {
382
                      target.click();
383
                  }
384
              }
385
          }
373 386
      }
374 387

  
375 388
      if ($('.ressource-item').length) {

Also available in: Unified diff