Skip to content

Commit

Permalink
[Per hour] Remove availability_per_hour feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
aivils committed Feb 16, 2018
1 parent 0cf6518 commit 6e88334
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 53 deletions.
1 change: 0 additions & 1 deletion app/controllers/admin/listing_shapes_controller.rb
Expand Up @@ -227,7 +227,6 @@ def common_locals(form:, count:, process_summary:, available_locs:)
display_knowledge_base_articles: APP_CONFIG.display_knowledge_base_articles.to_s == "true",
knowledge_base_url: APP_CONFIG.knowledge_base_url,
locale_name_mapping: available_locs.map { |name, l| [l, name] }.to_h,
availability_per_hour: FeatureFlagHelper.feature_enabled?(:availability_per_hour)
}
end

Expand Down
12 changes: 4 additions & 8 deletions app/controllers/listings_controller.rb
Expand Up @@ -150,8 +150,8 @@ def create
notify_about_new_listing

if shape.booking?
anchor = availability_per_hour_enabled && shape.booking_per_hour? ? 'manage-working-hours' : 'manage-availability'
@listing.working_hours_new_set(force_create: true) if availability_per_hour_enabled && shape.booking_per_hour?
anchor = shape.booking_per_hour? ? 'manage-working-hours' : 'manage-availability'
@listing.working_hours_new_set(force_create: true) if shape.booking_per_hour?
redirect_to listing_path(@listing, anchor: anchor, listing_just_created: true), status: 303
else
redirect_to @listing, status: 303
Expand Down Expand Up @@ -212,7 +212,7 @@ def update
@listing.upsert_field_values!(params.to_unsafe_hash[:custom_fields])

if update_successful
if availability_per_hour_enabled && shape.booking_per_hour? && !@listing.per_hour_ready
if shape.booking_per_hour? && !@listing.per_hour_ready
@listing.working_hours_new_set(force_create: true)
end
if @listing.location
Expand Down Expand Up @@ -477,7 +477,7 @@ def notify_about_new_listing

def create_booking(shape, listing_uuid)
if shape.present?
if availability_per_hour_enabled && shape.booking_per_hour?
if shape.booking_per_hour?
true
elsif APP_CONFIG.harmony_api_in_use && shape.booking?
create_bookable(@current_community.uuid_object, listing_uuid, @current_user.uuid_object).success
Expand All @@ -488,8 +488,4 @@ def create_booking(shape, listing_uuid)
true
end
end

def availability_per_hour_enabled
FeatureFlagHelper.feature_enabled?(:availability_per_hour)
end
end
10 changes: 2 additions & 8 deletions app/controllers/preauthorize_transactions_controller.rb
Expand Up @@ -115,13 +115,12 @@ def validate_initiate_params(marketplace_uuid:,
pickup_enabled:,
availability_enabled:,
listing:,
availability_per_hour_enabled:,
stripe_in_use:)

validate_delivery_method(tx_params: tx_params, shipping_enabled: shipping_enabled, pickup_enabled: pickup_enabled)
.and_then { validate_booking(tx_params: tx_params, quantity_selector: quantity_selector, stripe_in_use: stripe_in_use) }
.and_then { |result|
if availability_per_hour_enabled && tx_params[:per_hour]
if tx_params[:per_hour]
validate_booking_per_hour_timeslots(listing: listing, tx_params: tx_params)
elsif availability_enabled
validate_booking_timeslots(tx_params: tx_params,
Expand Down Expand Up @@ -268,7 +267,6 @@ def initiate
pickup_enabled: listing.pickup_enabled,
availability_enabled: listing.availability.to_sym == :booking,
listing: listing,
availability_per_hour_enabled: availability_per_hour_enabled,
stripe_in_use: StripeHelper.user_and_community_ready_for_payments?(listing.author_id, @current_community.id))
}

Expand Down Expand Up @@ -556,7 +554,7 @@ def show_shipping_price?(delivery_method)

def is_booking?(listing)
[ListingUnit::DAY, ListingUnit::NIGHT].include?(listing.quantity_selector) ||
(availability_per_hour_enabled && listing.unit_type.to_s == ListingUnit::HOUR && listing.availability == 'booking')
(listing.unit_type.to_s == ListingUnit::HOUR && listing.availability == 'booking')
end

def render_error_response(is_xhr, error_msg, redirect_params)
Expand Down Expand Up @@ -686,8 +684,4 @@ def query_person_entity(id)
def params_per_hour?
params[:per_hour] == '1'
end

def availability_per_hour_enabled
FeatureFlagHelper.feature_enabled?(:availability_per_hour)
end
end
1 change: 0 additions & 1 deletion app/services/feature_flag_service/store.rb
Expand Up @@ -22,7 +22,6 @@ class FeatureFlag
:searchpage_v1,
:manage_searchpage,
:stripe,
:availability_per_hour,
].to_set

def initialize(additional_flags:)
Expand Down
3 changes: 1 addition & 2 deletions app/view_utils/shape_service.rb
Expand Up @@ -152,8 +152,7 @@ def validate_upsert_opts(opts)
end

def enabled_units
units = ['day', 'night']
units.push('hour') if FeatureFlagHelper.feature_enabled?(:availability_per_hour)
units = ['day', 'night', 'hour']
units
end
end
48 changes: 23 additions & 25 deletions app/views/admin/listing_shapes/_shape_form_content.haml
Expand Up @@ -56,37 +56,35 @@
= check_box_tag(:shipping_enabled, "true", shape[:shipping_enabled], class: "checkbox-row-checkbox js-shipping-enabled")
= label_tag(:shipping_enabled, t("admin.listing_shapes.shipping_label"), class: "checkbox-row-label js-shipping-enabled-label")

- if harmony_in_use || availability_per_hour
- unless uneditable_fields[:availability]
- unless uneditable_fields[:availability]

.row
.col-12
= label_tag("", t("admin.listing_shapes.availability_title"), class: "input")
.row
.col-12
= label_tag("", t("admin.listing_shapes.availability_title"), class: "input")

- if display_knowledge_base_articles
= render :partial => "layouts/info_text", :locals => { :text => link_to(t("admin.listing_shapes.read_more_availability_management"), "#{knowledge_base_url}/knowledge-base/how-availability-management-works").html_safe }
- if display_knowledge_base_articles
= render :partial => "layouts/info_text", :locals => { :text => link_to(t("admin.listing_shapes.read_more_availability_management"), "#{knowledge_base_url}/knowledge-base/how-availability-management-works").html_safe }

.row
.col-12
= check_box_tag(:availability, "booking", shape[:availability] == 'booking', class: "checkbox-row-checkbox js-availability")
= label_tag(:availability, t("admin.listing_shapes.allow_providers_to_manage_availability"), class: "checkbox-row-label js-availability-label")
.row
.col-12
= check_box_tag(:availability, "booking", shape[:availability] == 'booking', class: "checkbox-row-checkbox js-availability")
= label_tag(:availability, t("admin.listing_shapes.allow_providers_to_manage_availability"), class: "checkbox-row-label js-availability-label")

- if availability_per_hour
.row
.col-12
= radio_button_tag(:availability_unit, "hour", shape[:availability] == 'booking' && shape[:availability_unit] == 'hour', class: "checkbox-row-checkbox js-availability-unit", style: "margin-left: 1em")
= label_tag(:availability_unit_hour, t("admin.listing_shapes.per_hour_availability"), class: "checkbox-row-label js-availability-unit-label")
.row
.col-12
= radio_button_tag(:availability_unit, "hour", shape[:availability] == 'booking' && shape[:availability_unit] == 'hour', class: "checkbox-row-checkbox js-availability-unit", style: "margin-left: 1em")
= label_tag(:availability_unit_hour, t("admin.listing_shapes.per_hour_availability"), class: "checkbox-row-label js-availability-unit-label")

- if harmony_in_use
.row
.col-12
= radio_button_tag(:availability_unit, "day", shape[:availability] == 'booking' && shape[:availability_unit] == 'day', class: "checkbox-row-checkbox js-availability-unit", style: "margin-left: 1em")
= label_tag(:availability_unit_day, t("admin.listing_shapes.per_day_availability"), class: "checkbox-row-label js-availability-unit-label")
- if harmony_in_use
.row
.col-12
= radio_button_tag(:availability_unit, "day", shape[:availability] == 'booking' && shape[:availability_unit] == 'day', class: "checkbox-row-checkbox js-availability-unit", style: "margin-left: 1em")
= label_tag(:availability_unit_day, t("admin.listing_shapes.per_day_availability"), class: "checkbox-row-label js-availability-unit-label")

.row
.col-12
= radio_button_tag(:availability_unit, "night", shape[:availability] == 'booking' && shape[:availability_unit] == 'night', class: "checkbox-row-checkbox js-availability-unit", style: "margin-left: 1em")
= label_tag(:availability_unit_night, t("admin.listing_shapes.per_night_availability"), class: "checkbox-row-label js-availability-unit-label")
.row
.col-12
= radio_button_tag(:availability_unit, "night", shape[:availability] == 'booking' && shape[:availability_unit] == 'night', class: "checkbox-row-checkbox js-availability-unit", style: "margin-left: 1em")
= label_tag(:availability_unit_night, t("admin.listing_shapes.per_night_availability"), class: "checkbox-row-label js-availability-unit-label")

.row
.col-12
Expand Down
3 changes: 1 addition & 2 deletions app/views/admin/listing_shapes/edit.haml
Expand Up @@ -18,8 +18,7 @@
count: count, locale_name_mapping: locale_name_mapping,
uneditable_fields: uneditable_fields, harmony_in_use: harmony_in_use,
display_knowledge_base_articles: display_knowledge_base_articles,
knowledge_base_url: knowledge_base_url,
availability_per_hour: availability_per_hour }
knowledge_base_url: knowledge_base_url }

.row
.col-12
Expand Down
3 changes: 1 addition & 2 deletions app/views/admin/listing_shapes/new.haml
Expand Up @@ -17,8 +17,7 @@
count: count, locale_name_mapping: locale_name_mapping,
uneditable_fields: uneditable_fields, harmony_in_use: harmony_in_use,
display_knowledge_base_articles: display_knowledge_base_articles,
knowledge_base_url: knowledge_base_url,
availability_per_hour: availability_per_hour }
knowledge_base_url: knowledge_base_url }

.row
.col-12
Expand Down
4 changes: 2 additions & 2 deletions app/views/listings/_listing_actions.haml
Expand Up @@ -37,7 +37,7 @@
- @listing_presenter.blocked_dates_result.on_error do
= t("listings.listing_actions.unable_load_availability")

- elsif FeatureFlagHelper.feature_enabled?(:availability_per_hour) && @listing_presenter.booking_per_hour?
- elsif @listing_presenter.booking_per_hour?
.input-daterange.input-group.clearfix
.datepicker-per-hour
.field
Expand Down Expand Up @@ -117,7 +117,7 @@
- if @listing_presenter.show_manage_availability
- availability_link_id = "edit-listing-availability-#{SecureRandom.urlsafe_base64(5)}"
.listing-view-admin-link
- if FeatureFlagHelper.feature_enabled?(:availability_per_hour) && @listing_presenter.booking_per_hour?
- if @listing_presenter.booking_per_hour?
%a.icon-with-text-container{id: availability_link_id, href: "#manage-working-hours"}
= icon_tag("calendar", ["icon-part"])
.text-part= t("web.listings.edit_listing_availability")
Expand Down
1 change: 0 additions & 1 deletion features/listings/user_books_listing_per_hour.feature
Expand Up @@ -8,7 +8,6 @@ Feature: User books listing per hour
| kassi_testperson2 |
# If tests failed then set current time in the furure!
And it is currently "2050-11-28 05:00:00"
Given community "test" has feature flag "availability_per_hour" enabled
Given community "test" has payment method "paypal" provisioned
Given community "test" has payment method "paypal" enabled by admin
Given community "test" has a listing shape offering services per hour
Expand Down
Expand Up @@ -4,7 +4,6 @@ Feature: User creates a new listing
@javascript
Scenario: Creating a new item "offering services" successfully
Given skip this scenario as phantomjs crashes
Given community "test" has feature flag "availability_per_hour" enabled
Given community "test" has payment method "paypal" provisioned
Given community "test" has payment method "paypal" enabled by admin
Given community "test" has a listing shape offering services per hour
Expand Down

0 comments on commit 6e88334

Please sign in to comment.