Skip to content

Commit

Permalink
Implemented CRUD operations for shop_items
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanyshak authored and sveredyuk committed May 12, 2021
1 parent 30a733a commit c01f319
Show file tree
Hide file tree
Showing 127 changed files with 2,488 additions and 100 deletions.
1 change: 1 addition & 0 deletions app/controllers/users/concerns/recaptcha.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Recaptcha

included do
attr_reader :recaptcha_error_message

helper_method :recaptcha_error_message
end

Expand Down
6 changes: 2 additions & 4 deletions app/helpers/admin/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ def icon(icon, text = nil)
"#{semantic_icon(icon)} #{text}".strip.html_safe
end

def controls
render layout: '/admin/shared/controls' do
yield
end
def controls(&block)
render layout: '/admin/shared/controls', &block
end
end
end
4 changes: 1 addition & 3 deletions app/helpers/admin/events_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def event_status_label(event)
class: ['ui label', BG_STATUS_CLASS[event.status.to_sym]]
end

# rubocop:disable Metrics/AbcSize
def event_visitors(event)
requested = event.pending_visit_requests.length
approved = event.approved_visit_requests.length
Expand All @@ -56,11 +55,10 @@ def event_visitors(event)
t('events.index.visitors.visited') => visited
}
end
# rubocop:enable Metrics/AbcSize

def event_verified_user_data(event)
verified = event.verified_visitors.length
newbies = event.newbie_visitors.length
newbies = event.newbie_visitors.length

"#{verified} / #{newbies}"
end
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/admin/navigation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ def admin_pages_link
link_to t('pages.plural'), admin_pages_path, class: class_for(:pages)
end

def admin_shop_link
link_to t('shop.singular'), admin_shop_items_path, class: class_for(:shop)
end

private

def class_for(item)
Expand Down
6 changes: 2 additions & 4 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ def become_a_speaker_link(**options)
link_to t('phrases.become_speaker'), BECOME_SPEAKER_URL, options.merge(target: '_blank')
end

def admin_area
def admin_area(&block)
return unless admin?

content_tag(:div, class: 'pk-admin-area') do
yield
end
content_tag(:div, class: 'pk-admin-area', &block)
end
end
2 changes: 0 additions & 2 deletions app/helpers/navigation_helper.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

module NavigationHelper
include Rails.application.routes.url_helpers

def events_link
link_to t('events.plural'), events_path
end
Expand Down
1 change: 1 addition & 0 deletions app/services/http_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class HttpClient
attr_reader :client

extend Forwardable

delegate %i[get put post delete] => :client
Expand Down
6 changes: 2 additions & 4 deletions app/services/pdf_reports/base_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ def generate_pdf
raise NotImplementedError, 'For subclasses only!'
end

def report
Prawn::Document.generate(report_file.path, report_options) do |pdf|
yield(pdf)
end
def report(&block)
Prawn::Document.generate(report_file.path, report_options, &block)
end

def report_file
Expand Down
12 changes: 6 additions & 6 deletions app/services/talk/fetch_external_video_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

class Talk
class FetchExternalVideoData < ApplicationService
VIDEO_ID_REGEX = %r{(?:.be\/|\/watch\?v=|\/(?=p\/))([\w\/\-]+)}x.freeze
VIDEO_ID_REGEX = %r{(?:.be/|/watch\?v=|/(?=p/))([\w/\-]+)}x.freeze

def self.fetch_all! # rubocop:disable Metrics/AbcSize
def self.fetch_all!
logger = Logger.new(Rails.root.join('log', 'fetch_external_video_data.log'))

logger.info "==================== #{Time.now} ===================="
Expand Down Expand Up @@ -40,10 +40,10 @@ def video

def video_id
@video_id ||= begin
talk.video_url.match(VIDEO_ID_REGEX)[1]
rescue StandardError
nil
end
talk.video_url.match(VIDEO_ID_REGEX)[1]
rescue StandardError
nil
end
end
end
end
3 changes: 1 addition & 2 deletions app/services/user/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ def initialize(user, params = {}, options = {})

private

attr_reader(*PERMITTED_KEYS)
attr_reader :user, :options
attr_reader(*PERMITTED_KEYS, :user, :options)

def user_params
PERMITTED_KEYS.inject({}) { |mem, key| mem.merge!(key => send(key)) }
Expand Down
1 change: 1 addition & 0 deletions app/services/user/squash_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def call
HAS_ONE = :has_one

attr_reader :params, :resource, :association_type, :foreign_key, :source_id, :destination_id, :squash, :conditions

delegate :success?, to: :form

def resolve_relations!
Expand Down
1 change: 1 addition & 0 deletions app/services/visit_request/real_time_update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def call
private

attr_reader :visit_request

delegate :event, to: :visit_request

def render_visit_request(visit_request)
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/admin/_navigation.slim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
= admin_email_templates_link
= admin_friends_link
= admin_pages_link

= admin_shop_link

// TOOD @VS: Move all menu items to registry. Or not ?
- Ez::Registry.data(:admin_primary_navigation).each do |menu_item|
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/app/_header.slim
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ header.pk-header class="#{header_classlist.compact.join(' ')}"
nav
ul.pk-list.pk-header__dropdown-list.js-dropdown-list
li.pk-list__unit.pk-header__li-list-wr
= link_to "shop", '/shop'
= link_to "shop", '/shop/items'
li.pk-list__unit.pk-header__li-list-wr
a = "info"
ul.pk-header__li-list
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/passwords/new.slim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ h2
= f.input :email, required: true, autofocus: true, placeholder: 'E-mail', label_html: { class: 'pk-input__label' }, input_html: { class: 'pk-input' }

.pk-input__container.mts
/ = recaptcha_tags
= recaptcha_tags
.div
.ui class='red pointing above label error'
= recaptcha_error_message
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/registrations/new.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ h2
.pk-input__container.mts.mbx = f.input :subscribed, as: :boolean, label: "Subscribe Me to Pivorak's Newsletter"

.pk-input__container.mtm
/ = recaptcha_tags
= recaptcha_tags
.div
.ui class='red pointing above label error'
= recaptcha_error_message
Expand Down
2 changes: 1 addition & 1 deletion components/courses/Guardfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"

# Note: The cmd option is now required due to the increasing number of ways
# NOTE: The cmd option is now required due to the increasing number of ways
# rspec may be run, below are examples of the most common uses.
# * bundler: 'bundle exec rspec'
# * bundler binstubs: 'bin/rspec'
Expand Down
2 changes: 1 addition & 1 deletion components/courses/spec/support/features_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module FeaturesHelpers
#
# Validation errors
#
def expect_an_error(hash_pair = {}, nope = false) # rubocop:disable Metrics/AbcSize
def expect_an_error(hash_pair = {}, nope = false)
field = hash_pair.keys.first
value = hash_pair.values.first
error_div = "div.#{field}.field_with_errors"
Expand Down
130 changes: 130 additions & 0 deletions components/shop/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
PATH
remote: .
specs:
shop (0.1.0)
rails (~> 5.2.2, >= 5.2.2.1)

GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.6)
actionpack (= 5.2.6)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.6)
actionpack (= 5.2.6)
actionview (= 5.2.6)
activejob (= 5.2.6)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.6)
actionview (= 5.2.6)
activesupport (= 5.2.6)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.6)
activesupport (= 5.2.6)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.2.6)
activesupport (= 5.2.6)
globalid (>= 0.3.6)
activemodel (5.2.6)
activesupport (= 5.2.6)
activerecord (5.2.6)
activemodel (= 5.2.6)
activesupport (= 5.2.6)
arel (>= 9.0)
activestorage (5.2.6)
actionpack (= 5.2.6)
activerecord (= 5.2.6)
marcel (~> 1.0.0)
activesupport (5.2.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (9.0.0)
builder (3.2.4)
coderay (1.1.3)
concurrent-ruby (1.1.8)
crass (1.0.6)
erubi (1.10.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
loofah (2.9.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (1.0.1)
method_source (1.0.0)
mini_mime (1.1.0)
minitest (5.14.4)
nio4r (2.5.7)
nokogiri (1.11.3-x86_64-darwin)
racc (~> 1.4)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
racc (1.5.2)
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.6)
actioncable (= 5.2.6)
actionmailer (= 5.2.6)
actionpack (= 5.2.6)
actionview (= 5.2.6)
activejob (= 5.2.6)
activemodel (= 5.2.6)
activerecord (= 5.2.6)
activestorage (= 5.2.6)
activesupport (= 5.2.6)
bundler (>= 1.3.0)
railties (= 5.2.6)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (5.2.6)
actionpack (= 5.2.6)
activesupport (= 5.2.6)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rake (13.0.3)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.4.2)
thor (1.1.0)
thread_safe (0.3.6)
tzinfo (1.2.9)
thread_safe (~> 0.1)
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)

PLATFORMS
x86_64-darwin-20

DEPENDENCIES
pry
shop!
sqlite3

BUNDLED WITH
2.2.16
2 changes: 1 addition & 1 deletion components/shop/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_files.include('lib/**/*.rb')
end

APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
load 'rails/tasks/engine.rake'

load 'rails/tasks/statistics.rake'
Expand Down
Loading

0 comments on commit c01f319

Please sign in to comment.