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 5, 2024
1 parent db3c49b commit 235f7c8
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions website_event_membership_restriction/views/event_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
inherit_id="website_event.registration_template"
priority="999"
>
<!-- Hide the existing element and recreate it as both class and t-att-class can't coexist -->
<xpath
expr="//form//div[@id='o_wevent_tickets_collapse']//button"
position="attributes"
Expand All @@ -17,9 +18,13 @@
expr="//form//div[@id='o_wevent_tickets_collapse']//button"
position="after"
>
<t
t-set="is_disabled_for_non_members"
t-value="event.registration_membership_only and (not request.env.user or 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_for_non_members else '')"
t-attf-id="#{event.id}"
>
Register
Expand All @@ -29,19 +34,22 @@
(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_for_non_members">
<a class="text-center small" href="/membership-info">Members only</a>
</t>
</xpath>
<!-- Hide the existing element and recreate it as both class and t-att-class can't coexist -->
<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_for_non_members"
t-value="event.registration_membership_only and (not request.env.user or 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_for_non_members else '')"
t-attf-id="#{event.id}"
>
Register
Expand All @@ -51,9 +59,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_for_non_members">
<a class="text-center small" href="/membership-info">Members only</a>
</t>
</xpath>
Expand Down

0 comments on commit 235f7c8

Please sign in to comment.