stay_commerce 0.1.11 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5861ce1241022b986eecc6189dbb408fc598a09d8918711c0c9610f917d24a6
4
- data.tar.gz: 061efeee0f6282c67ac3dcaf4e578f25032dcee4a173b46ccccf1073b09e7116
3
+ metadata.gz: 7666bce8280d873c254de1000f27e045c0de5fd8a3dec3bcae2ffbc3b5b0e321
4
+ data.tar.gz: 0e217c0d0723fda01c66d307b3296b581a9e786ed333d279033668cbcda6889e
5
5
  SHA512:
6
- metadata.gz: 745c862563d5b73069e9e17b9f4a98a6c67bc3f3034dcf5c166ee425a79fd16fc95806d80752f212b92fa8d368bff27224b5ed8a37792f4f542fae3c94e2c1db
7
- data.tar.gz: c508c74362a75aa3a0d2dbc5f5f01e6172dc3df0928fc10ebf8112a2565a80d2ba01ec8b1aa660890e5cb0f42ada171dc12b7e8072796cc9bff7671dddbb3215
6
+ metadata.gz: cdd0be0c0dc98f8b3227f5f7636db735df93a329ce0e7ba604aa2c9a82c3dda5a36d36ab016e04ead29e3517030971357fd65f76861538cc10ffccaf7c108007
7
+ data.tar.gz: ba03f68fdcb000c05c39904ccd94afea3732eeb8cb2f26667b31324259b31e8166ba4ed3088d4592a94dce0b1b723f9040226d59285b501e38356f7e2cd829f5
@@ -25,13 +25,13 @@ $(document).ready(function() {
25
25
  const roomTypeField = document.getElementById('room_type_field');
26
26
  const propertyCategoryData = document.getElementById('property-category-data');
27
27
 
28
- // const roomTypesByCategory = JSON.parse(propertyCategoryData.getAttribute('data-room-types'));
28
+ const roomTypesByCategory = JSON.parse(propertyCategoryData.getAttribute('data-room-types'));
29
29
 
30
- // window.updateRoomType = function(selectedCategoryId) {
31
- // if (roomTypesByCategory[selectedCategoryId]) {
32
- // roomTypeField.value = roomTypesByCategory[selectedCategoryId];
33
- // } else {
34
- // roomTypeField.value = '';
35
- // }
36
- // };
30
+ window.updateRoomType = function(selectedCategoryId) {
31
+ if (roomTypesByCategory[selectedCategoryId]) {
32
+ roomTypeField.value = roomTypesByCategory[selectedCategoryId];
33
+ } else {
34
+ roomTypeField.value = '';
35
+ }
36
+ };
37
37
  });
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+ module Stay
3
+ module ImageResizerConcern
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ before_action :resize_image, only: %i[update create]
8
+ end
9
+
10
+ private
11
+
12
+ def resize_image
13
+ image_params = resize_param_name
14
+ return unless image_params
15
+
16
+ Array(image_params).each do |image_param|
17
+ next unless image_param.respond_to?(:tempfile)
18
+
19
+ content_type = Marcel::MimeType.for(image_param.tempfile)
20
+
21
+ next unless content_type&.start_with?("image")
22
+
23
+ begin
24
+ ImageProcessing::MiniMagick
25
+ .source(image_param.tempfile)
26
+ .quality(85)
27
+ .call(destination: image_param.tempfile.path)
28
+ rescue StandardError => e
29
+ Rails.logger.error "Image processing failed: #{e.message}"
30
+ next
31
+ end
32
+ end
33
+ end
34
+
35
+ def resize_param_name
36
+ case controller_name
37
+ when "properties"
38
+ params[:property][:place_images] || params[:property][:cover_image]
39
+ else
40
+ params[:attachment]
41
+ end
42
+ end
43
+ end
44
+ end
@@ -27,12 +27,10 @@ module Devise
27
27
  token = service.success
28
28
 
29
29
  call_devise_trackable!(token.resource_owner)
30
-
31
30
  token_response = Devise::Api::Responses::TokenResponse.new(request, token: token, action: __method__)
32
31
  Devise.api.config.after_successful_sign_up.call(token.resource_owner, token, request)
33
32
  assign_role(token.resource_owner) if token.resource_owner
34
33
  data = ActiveModelSerializers::SerializableResource.new(token.resource_owner, serializer: UserSerializer).as_json
35
- UserMailer.welcome_email(token.resource_owner).deliver_later if token.resource_owner
36
34
  return render json: { access_token: token_response&.token.access_token, success: true }, status: token_response.status
37
35
  end
38
36
 
@@ -157,8 +155,6 @@ module Devise
157
155
  def assign_role(user)
158
156
  role = Stay::Role.find_by(name: params[:type])
159
157
  user.role_users.create(role_id: role&.id) if role.present?
160
- token = Random.hex(16)
161
- user.update(confirmation_token: token)
162
158
  end
163
159
 
164
160
  def sign_in_params
@@ -1,6 +1,7 @@
1
1
  module Stay
2
2
  module Admin
3
3
  class PropertiesController < Stay::Admin::BaseController
4
+ include Stay::ImageResizerConcern
4
5
  before_action :set_property, only: %i[show edit update destroy approve reject]
5
6
 
6
7
  def index
@@ -1,4 +1,5 @@
1
1
  class Stay::Api::V1::PropertiesController < Stay::BaseApiController
2
+ include Stay::ImageResizerConcern
2
3
  before_action :authenticate_devise_api_token!
3
4
  before_action :set_property, only: [ :show, :update, :destroy ]
4
5
  before_action :check_create_access, only: [ :create, :update ]
@@ -2,6 +2,7 @@ module Stay
2
2
  class Property < ApplicationRecord
3
3
  ACTIVE_STATUS = "active".freeze
4
4
  APPROVED = "approved".freeze
5
+ PROPERTY = "property".freeze
5
6
  include Rails.application.routes.url_helpers
6
7
  include CurrencyHelper
7
8
  include Stay::ControllerHelpers::Currency
@@ -29,15 +30,15 @@ module Stay
29
30
  has_many :prices, through: :rooms
30
31
  has_many :line_items, through: :variants_including_master
31
32
  has_many :bookings
32
- belongs_to :property_category, class_name: "Stay::PropertyCategory", optional: true
33
+ belongs_to :property_category, class_name: "Stay::PropertyCategory"
33
34
  belongs_to :property_type, class_name: "Stay::PropertyType"
34
35
  has_many :property_amenities, class_name: "Stay::PropertyAmenity", dependent: :destroy
35
- has_many :amenities, through: :property_amenities, class_name: "Stay::Amenity"
36
+ has_many :property_type_amenities, -> { where(amenity_type: PROPERTY) }, through: :property_amenities, source: :amenity, class_name: "Stay::Amenity"
36
37
  has_many :additional_rules, class_name: "Stay::AdditionalRule", dependent: :destroy
37
38
  has_many :property_house_rules, class_name: "Stay::PropertyHouseRule", dependent: :destroy
38
39
  has_many :house_rules, through: :property_house_rules, class_name: "Stay::HouseRule"
39
40
  has_many :property_features, class_name: "Stay::PropertyFeature", dependent: :destroy
40
- has_many :features, through: :property_features, class_name: "Stay::Feature"
41
+ has_many :property_type_features,-> { where(feature_type: PROPERTY) },through: :property_features,source: :feature, class_name: "Stay::Feature"
41
42
  has_many :property_taxes, class_name: "Stay::PropertyTax", dependent: :destroy
42
43
  has_many :taxes, through: :property_taxes, class_name: "Stay::Tax"
43
44
  has_many :store_properties, class_name: "Stay::StoreProperty", dependent: :destroy
@@ -1,6 +1,7 @@
1
1
  module Stay
2
2
  class PropertyCategory < ApplicationRecord
3
3
  has_many :properties, class_name: "Stay::Property", dependent: :nullify
4
- validates :name, presence: true, uniqueness: { case_sensitive: false }, format: { without: /\s/, message: "must contain no spaces" }
4
+ validates :name, presence: true, uniqueness: { case_sensitive: false },
5
+ format: { without: /_/, message: "must not contain underscores" }
5
6
  end
6
7
  end
@@ -1,9 +1,9 @@
1
1
  module Stay
2
2
  class PropertyType < ApplicationRecord
3
- validates :name, presence: true, uniqueness: { case_sensitive: false }, format: { without: /\s/, error: "must contain no spaces" }
3
+ validates :name, presence: true, uniqueness: { case_sensitive: false },
4
+ format: { without: /_/, message: "must not contain underscores" }
4
5
 
5
-
6
- has_many :properties
6
+ has_many :properties, class_name: "Stay::Property", dependent: :nullify
7
7
  def self.ransackable_attributes(auth_object = nil)
8
8
  %w[id name created_at updated_at]
9
9
  end
@@ -1,7 +1,3 @@
1
1
  class PropertyCategorySerializer < ActiveModel::Serializer
2
- attributes :id, :name, :property_count
3
-
4
- def property_count
5
- object.properties.approved.active.count
6
- end
2
+ attributes :id, :name
7
3
  end
@@ -12,11 +12,11 @@ class PropertySerializer < ActiveModel::Serializer
12
12
  belongs_to :user
13
13
 
14
14
  def amenities
15
- ActiveModelSerializers::SerializableResource.new(object.amenities.property.uniq, each_serializer: AmenitySerializer)
15
+ ActiveModelSerializers::SerializableResource.new(object.property_type_amenities, each_serializer: AmenitySerializer)
16
16
  end
17
17
 
18
18
  def features
19
- ActiveModelSerializers::SerializableResource.new(object.features.property.uniq, each_serializer: PropertyFeatureSerializer)
19
+ ActiveModelSerializers::SerializableResource.new(object.property_type_features, each_serializer: PropertyFeatureSerializer)
20
20
  end
21
21
 
22
22
  def is_shared_property
@@ -1,7 +1,3 @@
1
1
  class PropertyTypeSerializer < ActiveModel::Serializer
2
- attributes :id, :name, :property_count
3
-
4
- def property_count
5
- object.properties.approved.active.count
6
- end
2
+ attributes :id, :name
7
3
  end
@@ -1,7 +1,8 @@
1
1
  class UserSerializer < ActiveModel::Serializer
2
2
  include Rails.application.routes.url_helpers
3
+
3
4
  attributes :id, :email, :first_name, :full_name, :last_name, :phone, :gender, :is_user, :is_host, :date_of_birth,
4
- :image, :whatsapp_notification, :sms_notification, :image_file_name,
5
+ :image, :image_file_name, :about_me, :country, :country_code
5
6
 
6
7
  def full_name
7
8
  object.full_name
@@ -23,14 +24,6 @@ class UserSerializer < ActiveModel::Serializer
23
24
  object.profile_image.url || nil
24
25
  end
25
26
 
26
- def whatsapp_notification
27
- object&.preferences.present? ? object&.preferences["whatsapp_notification"]: false
28
- end
29
-
30
- def sms_notification
31
- object&.preferences.present? ? object&.preferences["sms_notification"]: false
32
- end
33
-
34
27
  def image_file_name
35
28
  object.profile_image&.filename&.to_s || nil
36
29
  end
@@ -0,0 +1,7 @@
1
+ class AddFieldToStayUsers < ActiveRecord::Migration[8.0]
2
+ def change
3
+ add_column :stay_users, :country, :string
4
+ add_column :stay_users, :about_me, :text
5
+ add_column :stay_users, :country_code, :string
6
+ end
7
+ end
data/lib/stay/version.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  module Stay
2
- VERSION = "0.1.11"
2
+ VERSION = "0.1.12"
3
3
  end
4
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stay_commerce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - w3villa-vikaspal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-07 00:00:00.000000000 Z
11
+ date: 2025-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -479,6 +479,7 @@ files:
479
479
  - app/assets/stylesheets/stay/webpixels.css
480
480
  - app/channels/chat_channel.rb
481
481
  - app/controllers/concerns/stay/booking_validations.rb
482
+ - app/controllers/concerns/stay/image_resizer_concern.rb
482
483
  - app/controllers/concerns/stay/stripe_concern.rb
483
484
  - app/controllers/devise/api/tokens_controller.rb
484
485
  - app/controllers/stay/admin/addresses_controller.rb
@@ -935,6 +936,7 @@ files:
935
936
  - db/migrate/20241205092943_create_friendly_id_slugs.rb
936
937
  - db/migrate/20241217044817_add_deleted_atto_stay_property.rb
937
938
  - db/migrate/20241230064432_modify_property_category_on_properties.rb
939
+ - db/migrate/20250407101335_add_field_to_stay_users.rb
938
940
  - db/seeds.rb
939
941
  - lib/stay.rb
940
942
  - lib/stay/controller_helpers/currency.rb