mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-02 22:52:21 +01:00
(wip) add pre-registration to event
This commit is contained in:
parent
022bbfc3c6
commit
e28286d3cc
@ -97,6 +97,7 @@ class API::EventsController < API::APIController
|
|||||||
event_preparams = params.required(:event).permit(:title, :description, :start_date, :start_time, :end_date, :end_time,
|
event_preparams = params.required(:event).permit(:title, :description, :start_date, :start_time, :end_date, :end_time,
|
||||||
:amount, :nb_total_places, :availability_id, :all_day, :recurrence,
|
:amount, :nb_total_places, :availability_id, :all_day, :recurrence,
|
||||||
:recurrence_end_at, :category_id, :event_theme_ids, :age_range_id, :event_type,
|
:recurrence_end_at, :category_id, :event_theme_ids, :age_range_id, :event_type,
|
||||||
|
:pre_registration, :pre_registration_end_date,
|
||||||
event_theme_ids: [],
|
event_theme_ids: [],
|
||||||
event_image_attributes: %i[id attachment],
|
event_image_attributes: %i[id attachment],
|
||||||
event_files_attributes: %i[id attachment _destroy],
|
event_files_attributes: %i[id attachment _destroy],
|
||||||
|
@ -55,6 +55,7 @@ export const EventForm: React.FC<EventFormProps> = ({ action, event, onError, on
|
|||||||
const [updatingEvent, setUpdatingEvent] = useState<Event>(null);
|
const [updatingEvent, setUpdatingEvent] = useState<Event>(null);
|
||||||
const [isActiveAccounting, setIsActiveAccounting] = useState<boolean>(false);
|
const [isActiveAccounting, setIsActiveAccounting] = useState<boolean>(false);
|
||||||
const [isActiveFamilyAccount, setIsActiveFamilyAccount] = useState<boolean>(false);
|
const [isActiveFamilyAccount, setIsActiveFamilyAccount] = useState<boolean>(false);
|
||||||
|
const [isAcitvePreRegistration, setIsActivePreRegistration] = useState<boolean>(event?.pre_registration);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
EventCategoryAPI.index()
|
EventCategoryAPI.index()
|
||||||
@ -241,6 +242,19 @@ export const EventForm: React.FC<EventFormProps> = ({ action, event, onError, on
|
|||||||
formState={formState}
|
formState={formState}
|
||||||
options={ageRangeOptions}
|
options={ageRangeOptions}
|
||||||
label={t('app.admin.event_form.age_range')} />}
|
label={t('app.admin.event_form.age_range')} />}
|
||||||
|
<FormSwitch control={control}
|
||||||
|
id="pre_registration"
|
||||||
|
label={t('app.admin.event_form.pre_registration')}
|
||||||
|
formState={formState}
|
||||||
|
tooltip={t('app.admin.event_form.pre_registration_help')}
|
||||||
|
onChange={setIsActivePreRegistration} />
|
||||||
|
{isAcitvePreRegistration &&
|
||||||
|
<FormInput id="pre_registration_end_date"
|
||||||
|
type="date"
|
||||||
|
register={register}
|
||||||
|
formState={formState}
|
||||||
|
label={t('app.admin.event_form.pre_registration_end_date')} />
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
@ -66,6 +66,8 @@ export interface Event {
|
|||||||
recurrence_end_at: Date,
|
recurrence_end_at: Date,
|
||||||
advanced_accounting_attributes?: AdvancedAccounting,
|
advanced_accounting_attributes?: AdvancedAccounting,
|
||||||
event_type: EventType,
|
event_type: EventType,
|
||||||
|
pre_registration?: boolean,
|
||||||
|
pre_registration_end_date?: TDateISODate | Date,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EventDecoration {
|
export interface EventDecoration {
|
||||||
|
@ -255,11 +255,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel-footer no-padder ng-scope" ng-if="event.amount && reservationIsValid()">
|
<div class="panel-footer no-padder ng-scope" ng-if="!event.pre_registration && event.amount && reservationIsValid()">
|
||||||
<button class="btn btn-valid btn-info btn-block p-l btn-lg text-u-c r-b text-base" ng-click="payEvent()" ng-if="reserve.totalSeats > 0">{{ 'app.public.events_show.confirm_and_pay' | translate }} {{reserve.amountTotal | currency}}</button>
|
<button class="btn btn-valid btn-info btn-block p-l btn-lg text-u-c r-b text-base" ng-click="payEvent()" ng-if="reserve.totalSeats > 0">{{ 'app.public.events_show.confirm_and_pay' | translate }} {{reserve.amountTotal | currency}}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel-footer no-padder ng-scope" ng-if="event.amount == 0 && reservationIsValid()">
|
<div class="panel-footer no-padder ng-scope" ng-if="(event.pre_registration || event.amount == 0) && reservationIsValid()">
|
||||||
<button class="btn btn-valid btn-info btn-block p-l btn-lg text-u-c r-b text-base" ng-click="validReserveEvent()" ng-if="reserve.totalSeats > 0" ng-disabled="attempting">{{ 'app.shared.buttons.confirm' | translate }}</button>
|
<button class="btn btn-valid btn-info btn-block p-l btn-lg text-u-c r-b text-base" ng-click="validReserveEvent()" ng-if="reserve.totalSeats > 0" ng-disabled="attempting">{{ 'app.shared.buttons.confirm' | translate }}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -5,7 +5,8 @@ class LocalPaymentPolicy < ApplicationPolicy
|
|||||||
def confirm_payment?
|
def confirm_payment?
|
||||||
# only admins and managers can offer free extensions of a subscription
|
# only admins and managers can offer free extensions of a subscription
|
||||||
has_free_days = record.shopping_cart.items.any? { |item| item.is_a? CartItem::FreeExtension }
|
has_free_days = record.shopping_cart.items.any? { |item| item.is_a? CartItem::FreeExtension }
|
||||||
|
event = record.shopping_cart.items.find { |item| item.is_a? CartItem::EventReservation }
|
||||||
|
|
||||||
((user.admin? || user.manager?) && record.shopping_cart.customer.id != user.id) || (record.price.zero? && !has_free_days)
|
((user.admin? || user.manager?) && record.shopping_cart.customer.id != user.id) || (record.price.zero? && !has_free_days) || event&.reservable&.pre_registration
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.extract! event, :id, :title, :description, :event_type
|
json.extract! event, :id, :title, :description, :event_type, :pre_registration, :pre_registration_end_date
|
||||||
if event.event_image
|
if event.event_image
|
||||||
json.event_image_attributes do
|
json.event_image_attributes do
|
||||||
json.id event.event_image.id
|
json.id event.event_image.id
|
||||||
|
@ -156,6 +156,9 @@ en:
|
|||||||
standard: "Event standard"
|
standard: "Event standard"
|
||||||
nominative: "Event nominative"
|
nominative: "Event nominative"
|
||||||
family: "Event family"
|
family: "Event family"
|
||||||
|
pre_registration: "Pre-registration"
|
||||||
|
pre_registration_help: "If this option is checked, administrators and managers must validate registrations before they become final."
|
||||||
|
pre_registration_end_date: "Pre-registration end date"
|
||||||
plan_form:
|
plan_form:
|
||||||
ACTION_title: "{ACTION, select, create{New} other{Update the}} plan"
|
ACTION_title: "{ACTION, select, create{New} other{Update the}} plan"
|
||||||
tab_settings: "Settings"
|
tab_settings: "Settings"
|
||||||
|
@ -156,6 +156,9 @@ fr:
|
|||||||
standard: "Evénement standard"
|
standard: "Evénement standard"
|
||||||
nominative: "Evénement nominatif"
|
nominative: "Evénement nominatif"
|
||||||
family: "Evénement famille"
|
family: "Evénement famille"
|
||||||
|
pre_registration: "Pré-inscription"
|
||||||
|
pre_registration_help: "Si cette option est cochée, les administrateurs et les gestionnaires devent valider les inscriptions avant qu'elles ne soient définitives."
|
||||||
|
pre_registration_end_date: "Date de fin de pré-inscription"
|
||||||
plan_form:
|
plan_form:
|
||||||
ACTION_title: "{ACTION, select, create{Nouvelle} other{Mettre à jour la}} formule d'abonnement"
|
ACTION_title: "{ACTION, select, create{Nouvelle} other{Mettre à jour la}} formule d'abonnement"
|
||||||
tab_settings: "Paramètres"
|
tab_settings: "Paramètres"
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Add pre-registration and pre_registration_end_date to event
|
||||||
|
class AddPreRegistrationToEvent < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
add_column :events, :pre_registration, :boolean, default: false
|
||||||
|
add_column :events, :pre_registration_end_date, :datetime
|
||||||
|
end
|
||||||
|
end
|
@ -1244,7 +1244,9 @@ CREATE TABLE public.events (
|
|||||||
age_range_id integer,
|
age_range_id integer,
|
||||||
category_id integer,
|
category_id integer,
|
||||||
deleted_at timestamp without time zone,
|
deleted_at timestamp without time zone,
|
||||||
event_type character varying DEFAULT 'standard'::character varying
|
event_type character varying DEFAULT 'standard'::character varying,
|
||||||
|
pre_registration boolean DEFAULT false,
|
||||||
|
pre_registration_end_date timestamp(6) without time zone
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -8937,6 +8939,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
|||||||
('20230524080448'),
|
('20230524080448'),
|
||||||
('20230524083558'),
|
('20230524083558'),
|
||||||
('20230524110215'),
|
('20230524110215'),
|
||||||
('20230525101006');
|
('20230525101006'),
|
||||||
|
('20230612123250');
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user