Beispiel #1
0
    def get_classcards(self, auth_user_id=None, public_only=True):
        """
            :param public_only: Defines whether or not to show only public classcards, True by default
                                False means all cards are returned
            Returns classcards for school
        """
        from .tools import OsTools

        db = current.db
        os_tools = OsTools()

        allow_trial_for_existing_customers = os_tools.get_sys_property(
            'shop_allow_trial_cards_for_existing_customers')

        query = (db.school_classcards.Archived == False)
        if public_only:
            query &= (db.school_classcards.PublicCard == True)

        if auth_user_id and allow_trial_for_existing_customers != 'on':
            from .os_customer import Customer

            customer = Customer(auth_user_id)
            existing_customer = customer.get_has_or_had_subscription_or_classcard(
            )

            if existing_customer:
                query &= (db.school_classcards.Trialcard == False)

        return db(query).select(db.school_classcards.ALL,
                                orderby=db.school_classcards.Trialcard
                                | db.school_classcards.Name)
Beispiel #2
0
def checkin_booking_options():
    """
        List booking options for a customer
    """
    cuID = request.vars['cuID']
    clsID = request.vars['clsID']
    date_formatted = request.vars['date']
    date = datestr_to_python(DATE_FORMAT, date_formatted)

    customer = Customer(cuID)
    cls = Class(clsID, date)
    starttime = cls.cls.Starttime.strftime(TIME_FORMAT)
    pretty_date = date.strftime('%B %d, %Y')
    classtype = db.school_classtypes(cls.cls.school_classtypes_id)
    location = db.school_locations(cls.cls.school_locations_id)

    response.title = T(classtype.Name)
    response.subtitle = SPAN(starttime, ' ', pretty_date)
    response.view = 'selfcheckin/checkin.html'

    return_url = URL('selfcheckin',
                     'checkin',
                     vars={
                         'clsID': clsID,
                         'date': date_formatted
                     })

    cls = Class(clsID, date)

    # Check if we should apply the trial check for existing customers
    trial = True
    trial_for_existing_customers = get_sys_property(
        'system_allow_trial_classes_for_existing_customers')
    if trial_for_existing_customers != 'on':
        existing_customer = customer.get_has_or_had_subscription_or_classcard()
        if existing_customer:
            trial = False

    ah = AttendanceHelper()
    options = ah.get_customer_class_booking_options_formatted(
        clsID,
        date,
        customer,
        trial=trial,
        list_type='selfcheckin',
        controller='classes')
    cancel = os_gui.get_button('noicon',
                               return_url,
                               title=T('Cancel'),
                               btn_size='')

    content = DIV(H3(T('Booking options for'),
                     ' ',
                     customer.row.display_name,
                     _class='center'),
                  BR(),
                  options,
                  DIV(BR(), cancel, _class="col-md-12 center"),
                  _class="row")

    back = os_gui.get_button('back', return_url)

    return dict(content=content, back=back)