예제 #1
0
파일: editors.py 프로젝트: mdanielo44/asso
 def before_save(self, xfer):
     xfer.is_new = (self.item.id is None)
     if xfer.getparam('autocreate', 0) == 1:
         self.item.send_email_param = (xfer.request.META.get(
             'HTTP_REFERER',
             xfer.request.build_absolute_uri()), xfer.language)
         self.item.season = Season.current_season()
         if self.item.adherent_id is None:
             current_contact = Individual.objects.get(
                 user=xfer.request.user)
             current_contact = current_contact.get_final_child()
             self.item.adherent = Adherent(id=current_contact.pk)
             self.item.adherent.save(new_num=True)
             self.item.adherent.__dict__.update(current_contact.__dict__)
             self.item.adherent.save()
             self.item.adherent_id = self.item.adherent.id
     if self.item.subscriptiontype.duration == 0:  # periodic
         season = self.item.season
         self.item.begin_date = season.begin_date
         self.item.end_date = season.end_date
     elif self.item.subscriptiontype.duration == 1:  # periodic
         periodid = xfer.getparam('period', 0)
         period = Period.objects.get(id=periodid)
         self.item.begin_date = period.begin_date
         self.item.end_date = period.end_date
     elif self.item.subscriptiontype.duration == 2:  # monthly
         month_num = xfer.getparam('month', '')
         self.item.begin_date = convert_date(month_num + '-01')
         self.item.end_date = same_day_months_after(self.item.begin_date,
                                                    1) - timedelta(days=1)
     elif self.item.subscriptiontype.duration == 3:  # calendar
         self.item.begin_date = convert_date(xfer.getparam(
             'begin_date', ''))
         self.item.end_date = same_day_months_after(self.item.begin_date,
                                                    12) - timedelta(days=1)
예제 #2
0
파일: editors.py 프로젝트: Diacamma2/asso
 def before_save(self, xfer):
     xfer.is_new = (self.item.id is None)
     if xfer.getparam('autocreate', 0) == 1:
         self.item.send_email_param = (xfer.request.META.get('HTTP_REFERER', xfer.request.build_absolute_uri()), xfer.language)
         self.item.season = Season.current_season()
         if self.item.adherent_id is None:
             current_contact = Individual.objects.get(user=xfer.request.user)
             current_contact = current_contact.get_final_child()
             self.item.adherent = Adherent(id=current_contact.pk)
             self.item.adherent.save(new_num=True)
             self.item.adherent.__dict__.update(current_contact.__dict__)
             self.item.adherent.save()
             self.item.adherent_id = self.item.adherent.id
     if self.item.subscriptiontype.duration == 0:  # periodic
         season = self.item.season
         self.item.begin_date = season.begin_date
         self.item.end_date = season.end_date
     elif self.item.subscriptiontype.duration == 1:  # periodic
         periodid = xfer.getparam('period', 0)
         period = Period.objects.get(id=periodid)
         self.item.begin_date = period.begin_date
         self.item.end_date = period.end_date
     elif self.item.subscriptiontype.duration == 2:  # monthly
         month_num = xfer.getparam('month', '')
         self.item.begin_date = convert_date(month_num + '-01')
         self.item.end_date = same_day_months_after(
             self.item.begin_date, 1) - timedelta(days=1)
     elif self.item.subscriptiontype.duration == 3:  # calendar
         self.item.begin_date = convert_date(
             xfer.getparam('begin_date', ''))
         self.item.end_date = same_day_months_after(
             self.item.begin_date, 12) - timedelta(days=1)
예제 #3
0
파일: editors.py 프로젝트: Diacamma2/asso
 def saving(self, xfer):
     if not xfer.has_changed:
         self.before_save(xfer)
         self.item.save()
     date = convert_date(xfer.getparam('begin_date'))
     for period_idx in range(4):
         Period.objects.create(season=xfer.item, begin_date=same_day_months_after(date, period_idx * 3),
                               end_date=same_day_months_after(date, (period_idx + 1) * 3) - timedelta(days=1))
     if len(Season.objects.all()) == 1:
         xfer.item.set_has_actif()
예제 #4
0
파일: editors.py 프로젝트: mdanielo44/asso
 def saving(self, xfer):
     if not xfer.has_changed:
         self.before_save(xfer)
         self.item.save()
     date = convert_date(xfer.getparam('begin_date'))
     for period_idx in range(4):
         Period.objects.create(
             season=xfer.item,
             begin_date=same_day_months_after(date, period_idx * 3),
             end_date=same_day_months_after(date, (period_idx + 1) * 3) -
             timedelta(days=1))
     if len(Season.objects.all()) == 1:
         xfer.item.set_has_actif()