Ejemplo n.º 1
0
 def edit(self, xfer):
     Season.current_season()
     date = XferCompFloat('date_min', 1900, 2100, 0)
     date.set_location(1, 5)
     date.set_needed(True)
     date.set_value(self.item.date_min)
     date.description = _("date min.")
     xfer.add_component(date)
     date = XferCompFloat('date_max', 1900, 2100, 0)
     date.set_location(1, 6)
     date.set_needed(True)
     date.set_value(self.item.date_max)
     date.description = _("date max.")
     xfer.add_component(date)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 def fillresponse(self):
     text = _(
         "{[b]}Do you want that those %d old selected adherent(s) has been renew?{[/b]}{[br/]}Same subscription(s) will be applicated.{[br/]}No validated bill will be created for each subscritpion.") % len(self.items)
     if self.confirme(text):
         dateref = convert_date(self.getparam("dateref", ""), Season.current_season().date_ref)
         for item in self.items:
             item.renew(dateref)
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 def fillresponse(self):
     self.params['autocreate'] = 1
     current_contact = Individual.objects.get(user=self.request.user)
     current_contact = current_contact.get_final_child()
     if isinstance(current_contact, Adherent):
         self.item.adherent = current_contact
         self.params['adherent'] = current_contact.id
     else:
         self.item.adherent = Adherent()
     self.item.season = Season.current_season()
     SubscriptionAddModify.fillresponse(self)
Ejemplo n.º 6
0
def default_params():
    Parameter.change_value(
        'member-team-text', 'group')
    Parameter.change_value(
        'member-activite-text', 'passion')
    Params.clear()
    default = Activity.objects.get(id=1)
    default.name = "activity1"
    default.description = "activity N°1"
    default.save()
    Activity.objects.create(name="activity2", description="activity N°2")
    Team.objects.create(name="team1", description="team N°1")
    Team.objects.create(name="team2", description="team N°2")
    Team.objects.create(name="team3", description="team N°3")
    Age.objects.create(name="Poussins", minimum=9, maximum=10)
    Age.objects.create(name="Benjamins", minimum=11, maximum=12)
    Age.objects.create(name="Minimes", minimum=13, maximum=14)
    Age.objects.create(name="Cadets", minimum=15, maximum=16)
    Age.objects.create(name="Juniors", minimum=17, maximum=18)
    Age.objects.create(name="Espoirs", minimum=19, maximum=21)
    Age.objects.create(name="Seniors", minimum=22, maximum=38)
    Age.objects.create(name="Vétérans", minimum=39, maximum=108)
    Document.objects.create(season=Season.current_season(), name="Doc 1")
    Document.objects.create(season=Season.current_season(), name="Doc 2")
Ejemplo n.º 7
0
def default_params():
    Parameter.change_value('member-team-text', 'group')
    Parameter.change_value('member-activite-text', 'passion')
    Parameter.change_value('member-tax-receipt', '708')
    Params.clear()
    default = Activity.objects.get(id=1)
    default.name = "activity1"
    default.description = "activity N°1"
    default.save()
    Activity.objects.create(name="activity2", description="activity N°2")
    Team.objects.create(name="team1", description="team N°1{[br/]}The bests")
    Team.objects.create(name="team2",
                        description="team N°2{[br/]}The chalengers")
    Team.objects.create(name="team3", description="team N°3{[br/]}The newbies")
    Age.objects.create(name="Poussins", minimum=9, maximum=10)
    Age.objects.create(name="Benjamins", minimum=11, maximum=12)
    Age.objects.create(name="Minimes", minimum=13, maximum=14)
    Age.objects.create(name="Cadets", minimum=15, maximum=16)
    Age.objects.create(name="Juniors", minimum=17, maximum=18)
    Age.objects.create(name="Espoirs", minimum=19, maximum=21)
    Age.objects.create(name="Seniors", minimum=22, maximum=38)
    Age.objects.create(name="Vétérans", minimum=39, maximum=108)
    Document.objects.create(season=Season.current_season(), name="Doc 1")
    Document.objects.create(season=Season.current_season(), name="Doc 2")
Ejemplo n.º 8
0
 def fillresponse(self, send_email=True):
     cmd_manager = CommandManager(self.getparam('CMD_FILE', ''), self.items)
     if self.getparam('SAVE') is None:
         dlg = self.create_custom(self.model)
         img = XferCompImage('img')
         img.set_value(self.icon_path())
         img.set_location(0, 0, 1, 4)
         dlg.add_component(img)
         lab = XferCompLabelForm('lbl_title')
         lab.set_value_as_title(self.caption)
         lab.set_location(1, 0, 2)
         dlg.add_component(lab)
         grid = XferCompGrid('AdhCmd')
         for fname, ftitle in cmd_manager.get_fields():
             grid.add_header(fname, ftitle)
         for cmd_id, cmd_item in cmd_manager.get_content_txt():
             for head_name, value in cmd_item.items():
                 grid.set_value(cmd_id, head_name, value)
         grid.set_location(1, 2, 2)
         grid.add_action(self.request, AdherentCommandModify.get_action(TITLE_MODIFY, "images/edit.png"), close=CLOSE_NO, unique=SELECT_SINGLE)
         grid.add_action(self.request, AdherentCommandDelete.get_action(TITLE_DELETE, "images/delete.png"), close=CLOSE_NO, unique=SELECT_SINGLE)
         dlg.params['CMD_FILE'] = cmd_manager.file_name
         dlg.add_component(grid)
         if len(grid.records) > 0:
             lab = XferCompLabelForm('lbl_send_email')
             lab.set_value_as_name(_('Send quotition by email for each adherent.'))
             lab.set_location(1, 3)
             dlg.add_component(lab)
             chk = XferCompCheck('send_email')
             chk.set_value(send_email)
             chk.set_location(2, 3)
             dlg.add_component(chk)
             dlg.add_action(AdherentCommand.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'SAVE': 'YES'})
         dlg.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
     else:
         dateref = convert_date(self.getparam("dateref", ""), Season.current_season().date_ref)
         if send_email:
             param_email = self.request.META.get('HTTP_REFERER', self.request.build_absolute_uri()), self.language
         else:
             param_email = None
         nb_sub, nb_bill = cmd_manager.create_subscription(dateref, param_email)
         if send_email:
             msg = _('%(nbsub)d new subscription and %(nbbill)d quotation have been sent.') % {'nbsub': nb_sub, 'nbbill': nb_bill}
         else:
             msg = _('%d new subscription have been prepared.') % nb_sub
         self.message(msg)
Ejemplo n.º 9
0
 def get_filter(self):
     team = self.getparam("team", ())
     activity = self.getparam("activity", ())
     genre = self.getparam("genre", 0)
     age = self.getparam("age", ())
     status = self.getparam("status", -1)
     dateref = convert_date(self.getparam("dateref", ""), Season.current_season().date_ref)
     if self.getparam('is_renew', False):
         date_one_year = same_day_months_after(dateref, -12)
         date_six_month = same_day_months_after(dateref, -6)
         date_three_month = same_day_months_after(dateref, -3)
         current_filter = Q(subscription__subscriptiontype__duration=0) & Q(
             subscription__end_date__gte=date_one_year)
         current_filter |= Q(subscription__subscriptiontype__duration=1) & Q(
             subscription__end_date__gte=date_six_month)
         current_filter |= Q(subscription__subscriptiontype__duration=2) & Q(
             subscription__end_date__gte=date_three_month)
         current_filter |= Q(subscription__subscriptiontype__duration=3) & Q(
             subscription__end_date__gte=date_one_year)
         exclude_filter = Q(subscription__begin_date__lte=dateref) & Q(
             subscription__end_date__gte=dateref)
     else:
         current_filter = Q(subscription__begin_date__lte=dateref) & Q(
             subscription__end_date__gte=dateref)
         exclude_filter = Q()
     if len(team) > 0:
         current_filter &= Q(subscription__license__team__in=team)
     if len(activity) > 0:
         current_filter &= Q(subscription__license__activity__in=activity)
     if len(age) > 0:
         age_filter = Q()
         for age_item in Age.objects.filter(id__in=age):
             age_filter |= Q(birthday__gte="%d-01-01" % (dateref.year - age_item.maximum)) & Q(
                 birthday__lte="%d-12-31" % (dateref.year - age_item.minimum))
         current_filter &= age_filter
     if genre != 0:
         current_filter &= Q(genre=genre)
     if status == -1:
         current_filter &= Q(subscription__status__in=(1, 2))
     else:
         current_filter &= Q(subscription__status=status)
     return (current_filter, exclude_filter)
Ejemplo n.º 10
0
 def fillresponse_header(self):
     self.new_tab(_("Season"))
     show_filter = self.getparam("show_filter", 0)
     lbl = XferCompLabelForm("lbl_showing")
     lbl.set_value_as_name(_("Show season"))
     lbl.set_location(0, 3)
     self.add_component(lbl)
     edt = XferCompSelect("show_filter")
     edt.set_select([(0, _("Near active")), (1, _("All"))])
     edt.set_value(show_filter)
     edt.set_location(1, 3)
     edt.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     self.add_component(edt)
     self.filter = Q()
     if show_filter == 0:
         try:
             year_ref = Season.current_season().reference_year
             designation_begin = "%d/%d" % (year_ref - 2, year_ref - 1)
             designation_end = "%d/%d" % (year_ref + 2, year_ref + 3)
             self.filter = Q(designation__gte=designation_begin) & Q(designation__lte=designation_end)
         except:
             pass
Ejemplo n.º 11
0
 def fillresponse_header(self):
     self.new_tab(_('Season'))
     show_filter = self.getparam('show_filter', 0)
     edt = XferCompSelect("show_filter")
     edt.set_select([(0, _('Near active')), (1, _('All'))])
     edt.set_value(show_filter)
     edt.set_location(0, 3)
     edt.description = _('Show season')
     edt.set_action(self.request,
                    self.get_action(),
                    modal=FORMTYPE_REFRESH,
                    close=CLOSE_NO)
     self.add_component(edt)
     self.filter = Q()
     if show_filter == 0:
         try:
             year_ref = Season.current_season().reference_year
             designation_begin = "%d/%d" % (year_ref - 2, year_ref - 1)
             designation_end = "%d/%d" % (year_ref + 2, year_ref + 3)
             self.filter = Q(designation__gte=designation_begin) & Q(
                 designation__lte=designation_end)
         except Exception:
             pass
Ejemplo n.º 12
0
 def edit(self, xfer):
     autocreate = xfer.getparam('autocreate', 0) == 1
     xfer.change_to_readonly("adherent")
     cmp_status = xfer.get_components('status')
     if autocreate:
         if Params.getvalue("member-subscription-mode") == 2:
             status = 1
         else:
             status = 0
         cmp_status.set_value(status)
         xfer.change_to_readonly("status")
         xfer.params['status'] = status
     elif self.item.id is None:
         del cmp_status.select_list[0]
         del cmp_status.select_list[-2]
         del cmp_status.select_list[-1]
     else:
         xfer.change_to_readonly("status")
     last_subscription = self.item.adherent.last_subscription
     cmp_subscriptiontype = xfer.get_components('subscriptiontype')
     if (self.item.id is not None) or autocreate:
         xfer.change_to_readonly('season')
     else:
         cmp_season = xfer.get_components('season')
         if self.item.season_id is None:
             self.item.season = Season.current_season()
             cmp_season.set_value(self.item.season.id)
         cmp_season.set_action(xfer.request,
                               xfer.get_action(),
                               close=CLOSE_NO,
                               modal=FORMTYPE_REFRESH)
         if (last_subscription is not None) and (
                 xfer.getparam('subscriptiontype') is None):
             cmp_subscriptiontype.set_value(
                 last_subscription.subscriptiontype.id)
     if self.item.subscriptiontype_id is None:
         if len(cmp_subscriptiontype.select_list) == 0:
             raise LucteriosException(IMPORTANT,
                                      _("No subscription type defined!"))
         cmp_subscriptiontype.get_json()
         self.item.subscriptiontype = SubscriptionType.objects.get(
             id=cmp_subscriptiontype.value)
     cmp_subscriptiontype.set_action(xfer.request,
                                     xfer.get_action(),
                                     close=CLOSE_NO,
                                     modal=FORMTYPE_REFRESH)
     row = xfer.get_max_row() + 1
     self._add_season_comp(xfer, row)
     if Params.getvalue("member-team-enable") and (len(
             Prestation.objects.all()) > 0) and (
                 (self.item.id is None) or (self.item.status in (0, 1))):
         xfer.filltab_from_model(1, row + 1, False, ['prestations'])
     elif self.item.id is None:
         xfer.item = License()
         if last_subscription is not None:
             licenses = last_subscription.license_set.all()
             if len(licenses) > 0:
                 xfer.item = licenses[0]
         xfer.fill_from_model(1, row + 1, False)
         xfer.item = self.item
         team = xfer.get_components('team')
         if team is not None:
             team.set_needed(True)
         activity = xfer.get_components('activity')
         if activity is not None:
             activity.set_needed(True)
Ejemplo n.º 13
0
    def fillresponse(self, season):
        if season is None:
            working_season = Season.current_season()
        else:
            working_season = Season.objects.get(id=season)
        img = XferCompImage('img')
        img.set_value(self.icon_path())
        img.set_location(0, 0)
        self.add_component(img)
        lab = XferCompLabelForm('lbl_season')
        lab.set_value_as_name(_('season'))
        lab.set_location(1, 0)
        self.add_component(lab)
        sel = XferCompSelect('season')
        sel.set_needed(True)
        sel.set_select_query(Season.objects.all())
        sel.set_value(working_season.id)
        sel.set_location(2, 0)
        sel.set_action(self.request, self.get_action('', ''), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        self.add_component(sel)
        stat_result = working_season.get_statistic()
        if len(stat_result) == 0:
            lab = XferCompLabelForm('lbl_season')
            lab.set_color('red')
            lab.set_value_as_infocenter(_('no subscription!'))
            lab.set_location(1, 1, 2)
            self.add_component(lab)
        else:
            tab_iden = 0
            for stat_title, stat_city, stat_type in stat_result:
                tab_iden += 1
                if (len(stat_city) > 0) and (len(stat_type) > 0):
                    self.new_tab(stat_title)
                    lab = XferCompLabelForm("lbltown_%d" % tab_iden)
                    lab.set_underlined()
                    lab.set_value(_("Result by city"))
                    lab.set_location(0, 1)
                    self.add_component(lab)
                    grid = XferCompGrid("town_%d" % tab_iden)
                    grid.add_header("city", _("city"))
                    grid.add_header("MajW", _("women major"))
                    grid.add_header("MajM", _("men major"))
                    grid.add_header("MinW", _("women minor"))
                    grid.add_header("MinM", _("men minor"))
                    grid.add_header("ratio", _("total (%)"))
                    cmp = 0
                    for stat_val in stat_city:
                        for stat_key in stat_val.keys():
                            grid.set_value(cmp, stat_key, stat_val[stat_key])
                        cmp += 1
                    grid.set_location(0, 2)
                    self.add_component(grid)

                    lab = XferCompLabelForm("lbltype_%d" % tab_iden)
                    lab.set_underlined()
                    lab.set_value(_("Result by type"))
                    lab.set_location(0, 3)
                    self.add_component(lab)
                    grid = XferCompGrid("type_%d" % tab_iden)
                    grid.add_header("type", _("type"))
                    grid.add_header("MajW", _("women major"))
                    grid.add_header("MajM", _("men major"))
                    grid.add_header("MinW", _("women minor"))
                    grid.add_header("MinM", _("men minor"))
                    grid.add_header("ratio", _("total (%)"))
                    cmp = 0
                    for stat_val in stat_type:
                        for stat_key in stat_val.keys():
                            if (stat_key == 'type') and not isinstance(stat_val['type'], six.text_type):
                                grid.set_value(cmp, stat_key, six.text_type(
                                    SubscriptionType.objects.get(id=stat_val['type'])))
                            else:
                                grid.set_value(
                                    cmp, stat_key, stat_val[stat_key])
                        cmp += 1
                    grid.set_location(0, 4)
                    self.add_component(grid)
        self.add_action(AdherentStatisticPrint.get_action(TITLE_PRINT, "images/print.png"),
                        close=CLOSE_NO, params={'classname': self.__class__.__name__})
        self.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
Ejemplo n.º 14
0
 def fillresponse(self):
     if self.confirme(_("Do you want to check the access right for all adherents ?")):
         if self.traitment("static/lucterios.CORE/images/info.png", _("Please, waiting..."), ""):
             nb_del, nb_add, nb_update = Season.current_season().check_connection()
             self.traitment_data[2] = _("{[center]}{[b]}Result{[/b]}{[/center]}{[br/]}%(nb_del)s removed connection(s).{[br/]}%(nb_add)s added connection(s).{[br/]}%(nb_update)s updated connection(s).") % {'nb_del': nb_del, 'nb_add': nb_add, 'nb_update': nb_update}
Ejemplo n.º 15
0
    def fillresponse_header(self):
        row = self.get_max_row() + 1
        team = self.getparam("team", ())
        activity = self.getparam("activity", ())
        genre = self.getparam("genre", 0)
        age = self.getparam("age", ())
        status = self.getparam("status", -1)
        dateref = convert_date(
            self.getparam("dateref", ""), Season.current_season().date_ref)

        if Params.getvalue("member-age-enable"):
            lbl = XferCompLabelForm('lblage')
            lbl.set_value_as_name(_("Age"))
            lbl.set_location(0, row)
            self.add_component(lbl)
            sel = XferCompCheckList('age')
            sel.set_select_query(Age.objects.all())
            sel.set_value(age)
            sel.set_location(1, row, 1, 2)
            self.add_component(sel)

        if Params.getvalue("member-team-enable"):
            lbl = XferCompLabelForm('lblteam')
            lbl.set_value_as_name(Params.getvalue("member-team-text"))
            lbl.set_location(2, row)
            self.add_component(lbl)
            sel = XferCompCheckList('team')
            sel.set_select_query(Team.objects.all())
            sel.set_value(team)
            sel.set_location(3, row, 1, 2)
            self.add_component(sel)

        if Params.getvalue("member-activite-enable"):
            lbl = XferCompLabelForm('lblactivity')
            lbl.set_value_as_name(Params.getvalue("member-activite-text"))
            lbl.set_location(4, row)
            self.add_component(lbl)
            sel = XferCompCheckList('activity')
            sel.set_select_query(Activity.objects.all())
            sel.set_value(activity)
            sel.set_location(5, row, 1, 2)
            self.add_component(sel)

        lbl = XferCompLabelForm('lbldateref')
        lbl.set_value_as_name(_("reference date"))
        lbl.set_location(6, row)
        self.add_component(lbl)

        dtref = XferCompDate('dateref')
        dtref.set_value(dateref)
        dtref.set_needed(True)
        dtref.set_location(7, row, 2)
        self.add_component(dtref)

        if Params.getvalue("member-filter-genre"):
            lbl = XferCompLabelForm('lblgenre')
            lbl.set_value_as_name(_("genre"))
            lbl.set_location(6, row + 1)
            self.add_component(lbl)
            sel = XferCompSelect('genre')
            list_genre = list(self.item.get_field_by_name('genre').choices)
            list_genre.insert(0, (0, '---'))
            sel.set_select(list_genre)
            sel.set_location(7, row + 1)
            sel.set_value(genre)
            self.add_component(sel)

        lbl = XferCompLabelForm('lblstatus')
        lbl.set_value_as_name(_("status"))
        lbl.set_location(6, row + 2)
        self.add_component(lbl)
        sel = XferCompSelect('status')
        list_status = list(Subscription.get_field_by_name('status').choices)
        del list_status[0]
        del list_status[-2]
        del list_status[-1]
        list_status.insert(0, (-1, '%s & %s' % (_('building'), _('valid'))))
        sel.set_select(list_status)
        sel.set_location(7, row + 2)
        sel.set_value(status)
        self.add_component(sel)

        btn = XferCompButton('btndateref')
        btn.set_location(8, row + 1, 1, 2)
        btn.set_action(self.request, self.get_action(_('Refresh'), ''),
                       modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        self.add_component(btn)
Ejemplo n.º 16
0
def summary_member(xfer):
    is_right = WrapAction.is_permission(xfer.request, 'member.change_adherent')
    try:
        current_adherent = Adherent.objects.get(user=xfer.request.user)
    except:
        current_adherent = None

    if is_right or (current_adherent is not None):
        row = xfer.get_max_row() + 1
        lab = XferCompLabelForm('membertitle')
        lab.set_value_as_infocenter(_("Adherents"))
        lab.set_location(0, row, 4)
        xfer.add_component(lab)
    if current_adherent is not None:
        ident = []
        if Params.getvalue("member-numero"):
            ident.append("%s %s" % (_('numeros'), current_adherent.num))
        if Params.getvalue("member-licence-enabled"):
            current_license = current_adherent.license
            if current_license is not None:
                ident.append(current_license)
        row = xfer.get_max_row() + 1
        lab = XferCompLabelForm('membercurrent')
        lab.set_value_as_header("{[br/]}".join(ident))
        lab.set_location(0, row, 4)
        xfer.add_component(lab)
    if is_right:
        row = xfer.get_max_row() + 1
        try:
            current_season = Season.current_season()
            dateref = current_season.date_ref
            lab = XferCompLabelForm('memberseason')
            lab.set_value_as_headername(six.text_type(current_season))
            lab.set_location(0, row + 1, 4)
            xfer.add_component(lab)
            nb_adh = len(Adherent.objects.filter(Q(subscription__begin_date__lte=dateref) & Q(
                subscription__end_date__gte=dateref) & Q(subscription__status=2)))
            lab = XferCompLabelForm('membernb')
            lab.set_value_as_header(_("Active adherents: %d") % nb_adh)
            lab.set_location(0, row + 2, 4)
            xfer.add_component(lab)
            nb_adhcreat = len(Adherent.objects.filter(
                Q(subscription__begin_date__lte=dateref) & Q(subscription__end_date__gte=dateref) & Q(subscription__status=1)))
            if nb_adhcreat > 0:
                lab = XferCompLabelForm('memberadhcreat')
                lab.set_value_as_header(_("No validated adherents: %d") % nb_adhcreat)
                lab.set_location(0, row + 3, 4)
                xfer.add_component(lab)
            nb_adhwait = len(Adherent.objects.filter(
                Q(subscription__begin_date__lte=dateref) & Q(subscription__end_date__gte=dateref) & Q(subscription__status=0)))
            if nb_adhwait > 0:
                lab = XferCompLabelForm('memberadhwait')
                lab.set_value_as_header(_("Adherents waiting moderation: %d") % nb_adhwait)
                lab.set_location(0, row + 4, 4)
                xfer.add_component(lab)
        except LucteriosException as lerr:
            lbl = XferCompLabelForm("member_error")
            lbl.set_value_center(six.text_type(lerr))
            lbl.set_location(0, row + 1, 4)
            xfer.add_component(lbl)
    if is_right or (current_adherent is not None):
        lab = XferCompLabelForm('member')
        lab.set_value_as_infocenter("{[hr/]}")
        lab.set_location(0, row + 5, 4)
        xfer.add_component(lab)
        return True
    else:
        return False
Ejemplo n.º 17
0
 def fillresponse(self, season):
     if season is None:
         working_season = Season.current_season()
     else:
         working_season = Season.objects.get(id=season)
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0)
     self.add_component(img)
     sel = XferCompSelect('season')
     sel.set_needed(True)
     sel.set_select_query(Season.objects.all())
     sel.set_value(working_season.id)
     sel.set_location(1, 0)
     sel.description = _('season')
     sel.set_action(self.request,
                    self.get_action('', ''),
                    modal=FORMTYPE_REFRESH,
                    close=CLOSE_NO)
     self.add_component(sel)
     stat_result = Degree.get_statistic(working_season)
     if len(stat_result) == 0:
         lab = XferCompLabelForm('lbl_season')
         lab.set_color('red')
         lab.set_value_as_infocenter(_('no degree!'))
         lab.set_location(1, 1, 2)
         self.add_component(lab)
     else:
         total = 0
         pos_y = 2
         for activity, sublist in stat_result:
             subtotal = 0
             if activity is not None:
                 lab = XferCompLabelForm("lblactivite_%d" % activity.id)
                 lab.set_italic()
                 lab.set_value(six.text_type(activity))
                 lab.set_location(0, pos_y, 3)
                 self.add_component(lab)
                 pos_y += 1
             for degree_name, val in sublist:
                 lab = XferCompLabelForm("title_%d" % pos_y)
                 lab.set_value(degree_name)
                 lab.set_location(1, pos_y)
                 self.add_component(lab)
                 lab = XferCompLabelForm("val_%d" % pos_y)
                 lab.set_value(six.text_type(val))
                 lab.set_location(2, pos_y)
                 self.add_component(lab)
                 subtotal += val
                 total += val
                 pos_y += 1
             if activity is not None:
                 lab = XferCompLabelForm("lblsubtotal_%d" % activity.id)
                 lab.set_value_as_header(_("Total"))
                 lab.set_location(1, pos_y)
                 self.add_component(lab)
                 lab = XferCompLabelForm("subtotal_%d" % activity.id)
                 lab.set_italic()
                 lab.set_value(six.text_type(subtotal))
                 lab.set_location(2, pos_y)
                 self.add_component(lab)
                 pos_y += 1
         lab = XferCompLabelForm("lbltotal")
         lab.set_value_as_headername(_("Total"))
         lab.set_location(1, pos_y)
         self.add_component(lab)
         lab = XferCompLabelForm("total")
         lab.set_value_as_name(six.text_type(total))
         lab.set_location(2, pos_y)
         self.add_component(lab)
     self.add_action(DegreeStatisticPrint.get_action(
         TITLE_PRINT, "images/print.png"),
                     close=CLOSE_NO,
                     params={'classname': self.__class__.__name__})
     self.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
Ejemplo n.º 18
0
 def edit(self, xfer):
     autocreate = xfer.getparam('autocreate', 0) == 1
     xfer.change_to_readonly("adherent")
     cmp_status = xfer.get_components('status')
     if autocreate:
         if Params.getvalue("member-subscription-mode") == 2:
             status = 1
         else:
             status = 0
         cmp_status.set_value(status)
         xfer.change_to_readonly("status")
         xfer.params['status'] = status
     elif self.item.id is None:
         del cmp_status.select_list[0]
         del cmp_status.select_list[-2]
         del cmp_status.select_list[-1]
     else:
         xfer.change_to_readonly("status")
     last_subscription = self.item.adherent.last_subscription
     cmp_subscriptiontype = xfer.get_components('subscriptiontype')
     if (self.item.id is not None) or autocreate:
         xfer.change_to_readonly('season')
     else:
         cmp_season = xfer.get_components('season')
         if self.item.season_id is None:
             self.item.season = Season.current_season()
             cmp_season.set_value(self.item.season.id)
         cmp_season.set_action(xfer.request, xfer.get_action(),
                               close=CLOSE_NO, modal=FORMTYPE_REFRESH)
         if (last_subscription is not None) and (xfer.getparam('subscriptiontype') is None):
             cmp_subscriptiontype.set_value(
                 last_subscription.subscriptiontype.id)
     if self.item.subscriptiontype_id is None:
         if len(cmp_subscriptiontype.select_list) == 0:
             raise LucteriosException(IMPORTANT, _("No subscription type defined!"))
         cmp_subscriptiontype.get_reponse_xml()
         self.item.subscriptiontype = SubscriptionType.objects.get(
             id=cmp_subscriptiontype.value)
     cmp_subscriptiontype.set_action(xfer.request, xfer.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
     row = xfer.get_max_row() + 1
     season = self.item.season
     if self.item.subscriptiontype.duration == 0:  # annually
         lbl = XferCompLabelForm("lbl_seasondates")
         lbl.set_location(1, row)
         lbl.set_value_as_name(_('annually'))
         xfer.add_component(lbl)
         lbl = XferCompLabelForm("seasondates")
         lbl.set_location(2, row)
         lbl.set_value("%s => %s" % (formats.date_format(
             season.begin_date, "SHORT_DATE_FORMAT"), formats.date_format(season.end_date, "SHORT_DATE_FORMAT")))
         xfer.add_component(lbl)
     elif self.item.subscriptiontype.duration == 1:  # periodic
         lbl = XferCompLabelForm("lbl_period")
         lbl.set_location(1, row)
         lbl.set_value_as_name(_('period'))
         xfer.add_component(lbl)
         sel = XferCompSelect('period')
         sel.set_needed(True)
         sel.set_select_query(season.period_set.all())
         sel.set_location(2, row)
         xfer.add_component(sel)
     elif self.item.subscriptiontype.duration == 2:  # monthly
         lbl = XferCompLabelForm("lbl_month")
         lbl.set_location(1, row)
         lbl.set_value_as_name(_('month'))
         xfer.add_component(lbl)
         sel = XferCompSelect('month')
         sel.set_needed(True)
         sel.set_select(season.get_months())
         sel.set_location(2, row)
         xfer.add_component(sel)
     elif self.item.subscriptiontype.duration == 3:  # calendar
         lbl = XferCompLabelForm("lbl_begin_date")
         lbl.set_location(1, row)
         lbl.set_value_as_name(_('begin date'))
         xfer.add_component(lbl)
         begindate = XferCompDate('begin_date')
         begindate.set_needed(True)
         begindate.set_value(season.date_ref)
         begindate.set_location(2, row)
         xfer.add_component(begindate)
     if self.item.id is None:
         xfer.item = License()
         if last_subscription is not None:
             licenses = last_subscription.license_set.all()
             if len(licenses) > 0:
                 xfer.item = licenses[0]
         xfer.fill_from_model(1, row + 1, False)
         xfer.item = self.item
         team = xfer.get_components('team')
         if team is not None:
             team.set_needed(True)
         activity = xfer.get_components('activity')
         if activity is not None:
             activity.set_needed(True)
Ejemplo n.º 19
0
def add_account_subscription(current_contact, xfer):
    if Params.getvalue("member-subscription-mode") > 0:
        current_subscription = Subscription.objects.filter(adherent_id=current_contact.id, season=Season.current_season())
        if len(current_subscription) == 0:
            xfer.new_tab(_('002@Subscription'))
            row = xfer.get_max_row() + 1
            btn = XferCompButton('btnnewsubscript')
            btn.set_location(1, row)
            btn.set_action(xfer.request, SubscriptionAddForCurrent.get_action(
                _('Subscription'), 'diacamma.member/images/adherent.png'), close=CLOSE_NO)
            xfer.add_component(btn)
Ejemplo n.º 20
0
 def fillresponse(self, season):
     if season is None:
         working_season = Season.current_season()
     else:
         working_season = Season.objects.get(id=season)
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0)
     self.add_component(img)
     lab = XferCompLabelForm('lbl_season')
     lab.set_value_as_name(_('season'))
     lab.set_location(1, 0)
     self.add_component(lab)
     sel = XferCompSelect('season')
     sel.set_needed(True)
     sel.set_select_query(Season.objects.all())
     sel.set_value(working_season.id)
     sel.set_location(2, 0)
     sel.set_action(self.request, self.get_action('', ''), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     self.add_component(sel)
     stat_result = Degree.get_statistic(working_season)
     if len(stat_result) == 0:
         lab = XferCompLabelForm('lbl_season')
         lab.set_color('red')
         lab.set_value_as_infocenter(_('no degree!'))
         lab.set_location(1, 1, 2)
         self.add_component(lab)
     else:
         total = 0
         pos_y = 2
         for activity, sublist in stat_result:
             subtotal = 0
             if activity is not None:
                 lab = XferCompLabelForm("lblactivite_%d" % activity.id)
                 lab.set_italic()
                 lab.set_value(six.text_type(activity))
                 lab.set_location(0, pos_y, 3)
                 self.add_component(lab)
                 pos_y += 1
             for degree_name, val in sublist:
                 lab = XferCompLabelForm("title_%d" % pos_y)
                 lab.set_value(degree_name)
                 lab.set_location(1, pos_y)
                 self.add_component(lab)
                 lab = XferCompLabelForm("val_%d" % pos_y)
                 lab.set_value(six.text_type(val))
                 lab.set_location(2, pos_y)
                 self.add_component(lab)
                 subtotal += val
                 total += val
                 pos_y += 1
             if activity is not None:
                 lab = XferCompLabelForm("lblsubtotal_%d" % activity.id)
                 lab.set_value_as_header(_("Total"))
                 lab.set_location(1, pos_y)
                 self.add_component(lab)
                 lab = XferCompLabelForm("subtotal_%d" % activity.id)
                 lab.set_italic()
                 lab.set_value(six.text_type(subtotal))
                 lab.set_location(2, pos_y)
                 self.add_component(lab)
                 pos_y += 1
         lab = XferCompLabelForm("lbltotal")
         lab.set_value_as_headername(_("Total"))
         lab.set_location(1, pos_y)
         self.add_component(lab)
         lab = XferCompLabelForm("total")
         lab.set_value_as_name(six.text_type(total))
         lab.set_location(2, pos_y)
         self.add_component(lab)
     self.add_action(DegreeStatisticPrint.get_action(TITLE_PRINT, "images/print.png"),
                     close=CLOSE_NO, params={'classname': self.__class__.__name__})
     self.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))