Skip to content

Commit

Permalink
[IMP-FIX] website_event_membership_restriction: Use variable to condi…
Browse files Browse the repository at this point in the history
…tion the button classes

Use variable to condition the button classes to avoid errors in the views and also adds better readability.
  • Loading branch information
pilarvargas-tecnativa committed Jun 4, 2024
1 parent db3c49b commit ca9f526
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions website_event_membership_restriction/views/event_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
expr="//form//div[@id='o_wevent_tickets_collapse']//button"
position="after"
>
<t
t-set="is_disabled"
t-value="event.registration_membership_only and (not request.env.user._is_public() and (request.env.user.partner_id.commercial_partner_id.membership_state not in ['paid', 'free'] or request.env.user.partner_id.membership_state not in ['paid', 'free']))"
/>
<button
type="submit"
t-att-class="'btn btn-primary o_wait_lazy_js a-submit ' + (event.registration_membership_only and (not request.env.user._is_public() and (request.env.user.partner_id.commercial_partner_id.membership_state not in ['paid', 'free'] or request.env.user.partner_id.membership_state not in ['paid', 'free']) and 'disabled' or ''))"
t-att-class="'btn btn-primary o_wait_lazy_js a-submit ' + ('disabled' if is_disabled else '')"
t-attf-id="#{event.id}"
>
Register
Expand All @@ -29,19 +33,21 @@
(only <t t-out="event.seats_available" /> available)
</t>
</button>
<t
t-if="event.registration_membership_only and (not request.env.user._is_public() and (request.env.user.partner_id.commercial_partner_id.membership_state not in ['paid', 'free'] or request.env.user.partner_id.membership_state not in ['paid', 'free']))"
>
<t t-if="is_disabled">
<a class="text-center small" href="/membership-info">Members only</a>
</t>
</xpath>
<xpath expr="//form//div[@t-else='']//button" position="attributes">
<attribute name="class">d-none</attribute>
</xpath>
<xpath expr="//form//div[@t-else='']//button" position="after">
<t
t-set="is_disabled"
t-value="event.registration_membership_only and (not request.env.user._is_public() and (request.env.user.partner_id.commercial_partner_id.membership_state not in ['paid', 'free'] or request.env.user.partner_id.membership_state not in ['paid', 'free']))"
/>
<button
type="submit"
t-att-class="'btn btn-primary o_wait_lazy_js a-submit ' + (event.registration_membership_only and (not request.env.user._is_public() and (request.env.user.partner_id.commercial_partner_id.membership_state not in ['paid', 'free'] or request.env.user.partner_id.membership_state not in ['paid', 'free']) and 'disabled' or ''))"
t-att-class="'btn btn-primary o_wait_lazy_js a-submit ' + ('disabled' if is_disabled else '')"
t-attf-id="#{event.id}"
>
Register
Expand All @@ -51,9 +57,7 @@
(only <t t-out="event.seats_available" /> available)
</t>
</button>
<t
t-if="event.registration_membership_only and (not request.env.user._is_public() and (request.env.user.partner_id.commercial_partner_id.membership_state not in ['paid', 'free'] or request.env.user.partner_id.membership_state not in ['paid', 'free']))"
>
<t t-if="is_disabled">
<a class="text-center small" href="/membership-info">Members only</a>
</t>
</xpath>
Expand Down

0 comments on commit ca9f526

Please sign in to comment.