mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-30 19:52:20 +01:00
(wip) add pre-registration to event
This commit is contained in:
parent
b7bcce75f3
commit
219e7f5913
@ -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,
|
||||
:amount, :nb_total_places, :availability_id, :all_day, :recurrence,
|
||||
:recurrence_end_at, :category_id, :event_theme_ids, :age_range_id, :event_type,
|
||||
:pre_registration, :pre_registration_end_date,
|
||||
event_theme_ids: [],
|
||||
event_image_attributes: %i[id attachment],
|
||||
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 [isActiveAccounting, setIsActiveAccounting] = useState<boolean>(false);
|
||||
const [isActiveFamilyAccount, setIsActiveFamilyAccount] = useState<boolean>(false);
|
||||
const [isAcitvePreRegistration, setIsActivePreRegistration] = useState<boolean>(event?.pre_registration);
|
||||
|
||||
useEffect(() => {
|
||||
EventCategoryAPI.index()
|
||||
@ -241,6 +242,19 @@ export const EventForm: React.FC<EventFormProps> = ({ action, event, onError, on
|
||||
formState={formState}
|
||||
options={ageRangeOptions}
|
||||
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>
|
||||
</section>
|
||||
|
||||
|
@ -66,6 +66,8 @@ export interface Event {
|
||||
recurrence_end_at: Date,
|
||||
advanced_accounting_attributes?: AdvancedAccounting,
|
||||
event_type: EventType,
|
||||
pre_registration?: boolean,
|
||||
pre_registration_end_date?: TDateISODate | Date,
|
||||
}
|
||||
|
||||
export interface EventDecoration {
|
||||
|
@ -255,11 +255,11 @@
|
||||
</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>
|
||||
</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>
|
||||
</div>
|
||||
|
||||
|
@ -5,7 +5,8 @@ class LocalPaymentPolicy < ApplicationPolicy
|
||||
def confirm_payment?
|
||||
# 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 }
|
||||
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
|
||||
|
@ -1,6 +1,6 @@
|
||||
# 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
|
||||
json.event_image_attributes do
|
||||
json.id event.event_image.id
|
||||
|
@ -156,6 +156,9 @@ en:
|
||||
standard: "Event standard"
|
||||
nominative: "Event nominative"
|
||||
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:
|
||||
ACTION_title: "{ACTION, select, create{New} other{Update the}} plan"
|
||||
tab_settings: "Settings"
|
||||
|
@ -156,6 +156,9 @@ fr:
|
||||
standard: "Evénement standard"
|
||||
nominative: "Evénement nominatif"
|
||||
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:
|
||||
ACTION_title: "{ACTION, select, create{Nouvelle} other{Mettre à jour la}} formule d'abonnement"
|
||||
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
|
@ -1237,7 +1237,9 @@ CREATE TABLE public.events (
|
||||
age_range_id integer,
|
||||
category_id integer,
|
||||
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
|
||||
);
|
||||
|
||||
|
||||
@ -9060,8 +9062,9 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20230524080448'),
|
||||
('20230524083558'),
|
||||
('20230524110215');
|
||||
('20230525101006');
|
||||
('20230626122844'),
|
||||
('20230626122947');
|
||||
('20230525101006');
|
||||
('20230612123250');
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user