1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-22 11:52:21 +01:00

(wip) save booking user for event nominatif

This commit is contained in:
Du Peng 2023-05-10 18:47:13 +02:00
parent 8c4602e535
commit 6888f00036
10 changed files with 150 additions and 9 deletions

View File

@ -264,11 +264,14 @@ Application.Controllers.controller('ShowEventController', ['$scope', '$state', '
const nbReservePlaces = priceType === 'normal' ? $scope.reserve.nbReservePlaces : $scope.reserve.tickets[priceType];
if (nbReservePlaces > nbBookingUsers) {
_.times(nbReservePlaces - nbBookingUsers, () => {
/*
if (!hasMemberInBookingUsers()) {
$scope.reserve.bookingUsers[priceType].push({ event_price_category_id: priceType === 'normal' ? null : priceType, booked_id: $scope.ctrl.member.id, booked_type: 'User', name: $scope.ctrl.member.name });
} else {
$scope.reserve.bookingUsers[priceType].push({ event_price_category_id: priceType === 'normal' ? null : priceType });
}
*/
$scope.reserve.bookingUsers[priceType].push({ event_price_category_id: priceType === 'normal' ? null : priceType });
});
} else {
_.times(nbBookingUsers - nbReservePlaces, () => {
@ -689,10 +692,14 @@ Application.Controllers.controller('ShowEventController', ['$scope', '$state', '
if (event.booking_nominative) {
for (const key of Object.keys($scope.reserve.bookingUsers)) {
for (const user of $scope.reserve.bookingUsers[key]) {
reservation.booking_users_attributes.push(user);
reservation.booking_users_attributes.push({
event_price_category_id: user.event_price_category_id,
name: user.name,
booked_id: user.booked_id,
booked_type: user.booked_type
});
}
}
console.log(reservation);
}
return { reservation };

View File

@ -119,9 +119,9 @@
<select ng-model="reserve.nbReservePlaces" ng-change="changeNbPlaces('normal')" ng-options="i for i in reserve.nbPlaces.normal">
</select> {{ 'app.public.events_show.ticket' | translate:{NUMBER:reserve.nbReservePlaces} }}
</div>
<div class="col-sm-12" ng-if="event.booking_nominative && reserve.nbReservePlaces > 0">
<div class="col-sm-12 m-b" ng-if="event.booking_nominative && reserve.nbReservePlaces > 0">
<div ng-repeat="user in reserve.bookingUsers.normal">
<label class="">Name</label>
<label class="" translate>{{ 'app.public.events_show.last_name_and_first_name '}}</label>
<input type="text" class="form-control" ng-model="user.name">
</div>
</div>
@ -132,9 +132,9 @@
<select ng-model="reserve.tickets[price.id]" ng-change="changeNbPlaces(price.id)" ng-options="i for i in reserve.nbPlaces[price.id]">
</select> {{ 'app.public.events_show.ticket' | translate:{NUMBER:reserve.tickets[price.id]} }}
</div>
<div class="col-sm-12" ng-if="event.booking_nominative && reserve.tickets[price.id] > 0">
<div class="col-sm-12 m-b" ng-if="event.booking_nominative && reserve.tickets[price.id] > 0">
<div ng-repeat="user in reserve.bookingUsers[price.id]">
<label class="">Name</label>
<label class="" translate>{{ 'app.public.events_show.last_name_and_first_name '}}</label>
<input type="text" class="form-control" ng-model="user.name">
</div>
</div>
@ -169,7 +169,7 @@
<div ng-hide="isCancelled(reservation)" class="well well-warning">
<div class="font-sbold text-u-c text-sm">{{ 'app.public.events_show.you_booked_DATE' | translate:{DATE:(reservation.created_at | amDateFormat:'L LT')} }}</div>
<div class="font-sbold text-sm" ng-if="reservation.nb_reserve_places > 0">{{ 'app.public.events_show.full_price_' | translate }} {{reservation.nb_reserve_places}} {{ 'app.public.events_show.ticket' | translate:{NUMBER:reservation.nb_reserve_places} }}</div>
<div class="font-sbold text-sm" ng-repeat="ticket in reservation.tickets">
<div class="font-sbold text-sm" ng-repeat="ticket in reservation.tickets_attributes">
{{ticket.event_price_category.price_category.name}} : {{ticket.booked}} {{ 'app.public.events_show.ticket' | translate:{NUMBER:ticket.booked} }}
</div>
<div class="clear" ng-if="event.recurrence_events.length > 0 && reservationCanModify(reservation)">

5
app/models/cart_item.rb Normal file
View File

@ -0,0 +1,5 @@
module CartItem
def self.table_name_prefix
"cart_item_"
end
end

View File

@ -13,6 +13,11 @@ class CartItem::EventReservation < CartItem::Reservation
foreign_type: 'cart_item_type', as: :cart_item
accepts_nested_attributes_for :cart_item_reservation_slots
has_many :cart_item_event_reservation_booking_users, class_name: 'CartItem::EventReservationBookingUser', dependent: :destroy,
inverse_of: :cart_item_event_reservation,
foreign_key: 'cart_item_event_reservation_id'
accepts_nested_attributes_for :cart_item_event_reservation_booking_users
belongs_to :operator_profile, class_name: 'InvoicingProfile'
belongs_to :customer_profile, class_name: 'InvoicingProfile'
@ -63,6 +68,14 @@ class CartItem::EventReservation < CartItem::Reservation
booked: t.booked
}
end,
booking_users_attributes: cart_item_event_reservation_booking_users.map do |b|
{
event_price_category_id: b.event_price_category_id,
booked_type: b.booked_type,
booked_id: b.booked_id,
name: b.name
}
end,
nb_reserve_places: normal_tickets,
statistic_profile_id: StatisticProfile.find_by(user: customer).id
)

View File

@ -0,0 +1,10 @@
# frozen_string_literal: true
# A relation table between a pending event reservation and reservation users for this event
class CartItem::EventReservationBookingUser < ApplicationRecord
self.table_name = 'cart_item_event_reservation_booking_users'
belongs_to :cart_item_event_reservation, class_name: 'CartItem::EventReservation', inverse_of: :cart_item_event_reservation_booking_users
belongs_to :event_price_category, inverse_of: :cart_item_event_reservation_tickets
belongs_to :booked, polymorphic: true
end

View File

@ -171,7 +171,8 @@ class CartService
event: reservable,
cart_item_reservation_slots_attributes: cart_item[:slots_reservations_attributes],
normal_tickets: cart_item[:nb_reserve_places],
cart_item_event_reservation_tickets_attributes: cart_item[:tickets_attributes] || {})
cart_item_event_reservation_tickets_attributes: cart_item[:tickets_attributes] || {},
cart_item_event_reservation_booking_users_attributes: cart_item[:booking_users_attributes] || {})
when Space
CartItem::SpaceReservation.new(customer_profile: @customer.invoicing_profile,
operator_profile: @operator.invoicing_profile,

View File

@ -357,6 +357,7 @@ en:
view_event_list: "View events to come"
share_on_facebook: "Share on Facebook"
share_on_twitter: "Share on Twitter"
last_name_and_first_name: "Last name and first name"
#public calendar
calendar:
calendar: "Calendar"

View File

@ -357,6 +357,7 @@ fr:
view_event_list: "Voir les événements à venir"
share_on_facebook: "Partager sur Facebook"
share_on_twitter: "Partager sur Twitter"
last_name_and_first_name: "Nom et prénom"
#public calendar
calendar:
calendar: "Calendrier"

View File

@ -0,0 +1,15 @@
# frozen_string_literal: true
# A relation table between a pending event reservation and reservation users for this event
class CreateCartItemEventReservationBookingUsers < ActiveRecord::Migration[7.0]
def change
create_table :cart_item_event_reservation_booking_users do |t|
t.string :name
t.belongs_to :cart_item_event_reservation, foreign_key: true, index: { name: 'index_cart_item_booking_users_on_cart_item_event_reservation' }
t.references :event_price_category, foreign_key: true, index: { name: 'index_cart_item_booking_users_on_event_price_category' }
t.references :booked, polymorphic: true
t.timestamps
end
end
end

View File

@ -588,6 +588,41 @@ CREATE SEQUENCE public.cart_item_coupons_id_seq
ALTER SEQUENCE public.cart_item_coupons_id_seq OWNED BY public.cart_item_coupons.id;
--
-- Name: cart_item_event_reservation_booking_users; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.cart_item_event_reservation_booking_users (
id bigint NOT NULL,
name character varying,
cart_item_event_reservation_id bigint,
event_price_category_id bigint,
booked_type character varying,
booked_id bigint,
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL
);
--
-- Name: cart_item_event_reservation_booking_users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.cart_item_event_reservation_booking_users_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: cart_item_event_reservation_booking_users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.cart_item_event_reservation_booking_users_id_seq OWNED BY public.cart_item_event_reservation_booking_users.id;
--
-- Name: cart_item_event_reservation_tickets; Type: TABLE; Schema: public; Owner: -
--
@ -4398,6 +4433,13 @@ ALTER TABLE ONLY public.booking_users ALTER COLUMN id SET DEFAULT nextval('publi
ALTER TABLE ONLY public.cart_item_coupons ALTER COLUMN id SET DEFAULT nextval('public.cart_item_coupons_id_seq'::regclass);
--
-- Name: cart_item_event_reservation_booking_users id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.cart_item_event_reservation_booking_users ALTER COLUMN id SET DEFAULT nextval('public.cart_item_event_reservation_booking_users_id_seq'::regclass);
--
-- Name: cart_item_event_reservation_tickets id; Type: DEFAULT; Schema: public; Owner: -
--
@ -5252,6 +5294,14 @@ ALTER TABLE ONLY public.cart_item_coupons
ADD CONSTRAINT cart_item_coupons_pkey PRIMARY KEY (id);
--
-- Name: cart_item_event_reservation_booking_users cart_item_event_reservation_booking_users_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.cart_item_event_reservation_booking_users
ADD CONSTRAINT cart_item_event_reservation_booking_users_pkey PRIMARY KEY (id);
--
-- Name: cart_item_event_reservation_tickets cart_item_event_reservation_tickets_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
@ -6192,6 +6242,20 @@ CREATE INDEX index_booking_users_on_event_price_category_id ON public.booking_us
CREATE INDEX index_booking_users_on_reservation_id ON public.booking_users USING btree (reservation_id);
--
-- Name: index_cart_item_booking_users_on_cart_item_event_reservation; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_cart_item_booking_users_on_cart_item_event_reservation ON public.cart_item_event_reservation_booking_users USING btree (cart_item_event_reservation_id);
--
-- Name: index_cart_item_booking_users_on_event_price_category; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_cart_item_booking_users_on_event_price_category ON public.cart_item_event_reservation_booking_users USING btree (event_price_category_id);
--
-- Name: index_cart_item_coupons_on_coupon_id; Type: INDEX; Schema: public; Owner: -
--
@ -6213,6 +6277,13 @@ CREATE INDEX index_cart_item_coupons_on_customer_profile_id ON public.cart_item_
CREATE INDEX index_cart_item_coupons_on_operator_profile_id ON public.cart_item_coupons USING btree (operator_profile_id);
--
-- Name: index_cart_item_event_reservation_booking_users_on_booked; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_cart_item_event_reservation_booking_users_on_booked ON public.cart_item_event_reservation_booking_users USING btree (booked_type, booked_id);
--
-- Name: index_cart_item_event_reservations_on_customer_profile_id; Type: INDEX; Schema: public; Owner: -
--
@ -7548,6 +7619,14 @@ ALTER TABLE ONLY public.payment_schedules
ADD CONSTRAINT fk_rails_00308dc223 FOREIGN KEY (wallet_transaction_id) REFERENCES public.wallet_transactions(id);
--
-- Name: cart_item_event_reservation_booking_users fk_rails_0964335a37; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.cart_item_event_reservation_booking_users
ADD CONSTRAINT fk_rails_0964335a37 FOREIGN KEY (event_price_category_id) REFERENCES public.event_price_categories(id);
--
-- Name: cart_item_free_extensions fk_rails_0d11862969; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@ -7820,6 +7899,14 @@ ALTER TABLE ONLY public.chained_elements
ADD CONSTRAINT fk_rails_4fad806cca FOREIGN KEY (previous_id) REFERENCES public.chained_elements(id);
--
-- Name: cart_item_event_reservation_booking_users fk_rails_5206c6ca4a; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.cart_item_event_reservation_booking_users
ADD CONSTRAINT fk_rails_5206c6ca4a FOREIGN KEY (cart_item_event_reservation_id) REFERENCES public.cart_item_event_reservations(id);
--
-- Name: cart_item_event_reservation_tickets fk_rails_5307e8aab8; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@ -8839,6 +8926,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20230328094809'),
('20230331132506'),
('20230509121907'),
('20230509161557');
('20230509161557'),
('20230510141305');