diff --git a/app/assets/stylesheets/admin/checkout_products.css b/app/assets/stylesheets/admin/checkout_products.css
deleted file mode 100644
index 2f5bbca9b..000000000
--- a/app/assets/stylesheets/admin/checkout_products.css
+++ /dev/null
@@ -1,154 +0,0 @@
-.panel-heading {
- height: 39px;
- padding-top: 0;
- line-height: 39px;
-}
-
-table.table.table-linked > tbody > tr:hover > td > a {
- text-decoration: none;
-}
-
-table.table.table-linked > tbody > tr > td > a:hover {
- text-decoration: underline;
-}
-
-.date-input {
- display: inline-block;
-}
-
-.date-input input {
- font-weight: bold;
- font-size: 14px;
- line-height: 14px;
- margin-left: 5px;
- display: inline-block;
- position: relative;
- padding: 5px;
- outline: none;
- background: transparent;
-}
-
-.update-side-bar {
- position: fixed;
- right: 0;
- max-height: calc(100% - 70px);
- top: 65px;
- width: calc(50% - 100px);
- overflow-y: scroll;
-}
-
-.new-product {
- width: 36.5px;
- height: 36.5px;
- font-size: 30px;
- padding: 0;
- line-height: 30px;
- float: right;
-}
-
-.card-header-text {
- float: left;
- line-height: 36.5px;
-}
-
-.edit-product-form, .edit-product-form-lower {
- margin-left: 158px;
-}
-
-.save-btn {
- margin-top: 20px;
- float: right;
-}
-
-@media (min-width: 768px) {
- form .panel-body {
- position: relative;
- }
-
- form span.thumb {
- position: absolute;
- top: 67px;
- height: 128px;
- width: 128px;
- overflow: hidden;
- }
-
- table.table.table-linked > tbody > tr > td.text-right {
- padding-right: 30px;
- }
-}
-
-@media (max-width: 1400px) {
- .product-cards {
- flex-flow: wrap-reverse;
- }
-
- .col-md-8, .col-md-4 {
- max-width: 100%;
- flex: none;
- }
-
- .edit-product-form-lower {
- margin-left: 0px;
- }
-}
-
-@media (max-width: 1030px) {
- .update-side-bar {
- position: relative;
- float: left;
- width: 100%;
- padding: 0;
- top: inherit;
- }
-
- .col-md-6 {
- max-width: 100%;
- flex: none;
- }
-}
-
-tr.total {
- font-weight: bold;
-}
-
-.table span.fa-sort-asc {
- color: green;
- position: relative;
- top: 6px;
-}
-
-.table span.fa-sort-desc {
- color: red;
-}
-
-tr.inactive {
- text-decoration: line-through;
-}
-
-p.uuid {
- margin-bottom: 0;
-}
-
-.ui-select.year {
- width: 110px;
- margin-left: 5px;
-}
-
-.ui-select.year select {
- font-size: 14px;
- line-height: 14px;
-}
-
-a.col-md-4, a.col-md-4:hover {
- text-decoration: none;
-}
-
-a.panel:hover {
- text-decoration: none;
-}
-
-.new-product a {
- color: #fff;
- text-decoration: none;
-}
\ No newline at end of file
diff --git a/app/assets/stylesheets/admin/apps.css b/app/assets/stylesheets/admin/transactions.css
similarity index 53%
rename from app/assets/stylesheets/admin/apps.css
rename to app/assets/stylesheets/admin/transactions.css
index 3c5d918e3..b1871e610 100644
--- a/app/assets/stylesheets/admin/apps.css
+++ b/app/assets/stylesheets/admin/transactions.css
@@ -39,67 +39,6 @@ tr.total {
border-top: 2px solid #dddddd;
}
-/* Members - [Member] - Checkout */
-div#credit.input-group {
- display: inline;
- width: auto;
- float: right;
-}
-
-div#credit.input-group > span.input-group-btn,
-div#credit.input-group > span {
- float: right;
- margin-left: 2px;
-}
-
-div#credit.input-group > *,
-div#credit.input-group > * > * {
- display: inline-block;
-}
-
-div#credit.input-group > .input-symbol > input {
- width: 80px;
-}
-
-div#credit.input-group select {
- background-color: white;
- height: 32px;
-}
-
-/* Apps - Checkout - Opwaarderen */
-#credit form.form-inline > .form-group {
- padding: 0;
-}
-
-@media (min-width: 768px) {
- #credit form.form-inline > .form-group {
- display: block;
- }
-}
-
-@media (min-width: 992px) {
- #credit form.form-inline > .form-group.amount {
- margin-left: 3.33%;
- width: 30%;
- }
-}
-
-#credit form.form-inline > .form-group > select.form-control,
-#credit form.form-inline > .form-group > input.form-control,
-#credit form.form-inline > .form-group > button.form-control {
- width: 100%;
- height: 30px;
- margin: 5px 0;
- padding: 1px 12px;
-}
-
-#credit .panel-body > ul.dropdown-menu {
- display: none;
- position: absolute;
- left: 0;
- top: 50px;
-}
-
.table span.fa-sort-asc {
color: green;
position: relative;
diff --git a/app/controllers/admin/checkout_products_controller.rb b/app/controllers/admin/checkout_products_controller.rb
deleted file mode 100644
index 8b060e35d..000000000
--- a/app/controllers/admin/checkout_products_controller.rb
+++ /dev/null
@@ -1,128 +0,0 @@
-#:nodoc:
-class Admin::CheckoutProductsController < ApplicationController
- # replaced with calls in each of the methods
- # impressionist :actions => [ :activate_card, :change_funds ]
- respond_to :json, only: [:activate_card, :change_funds]
-
- def index
- @products = CheckoutProduct.order(active: :desc, category: :asc, name: :asc).last_version
- @years = (2015..Date.today.study_year).map { |year| ["#{ year }-#{ year + 1 }", year] }.reverse
-
- @new = CheckoutProduct.new
-
- render('admin/apps/products')
- end
-
- def show
- @products = CheckoutProduct.order(active: :desc, category: :asc, name: :asc).last_version
- @years = (2015..Date.today.study_year).map { |year| ["#{ year }-#{ year + 1 }", year] }.reverse
-
- @product = CheckoutProduct.find_by(id: params[:id])
- @total = @product.sales(params['year']).map do |sale|
- sale.first[0].price * sale.first[1] unless sale.first[1].nil?
- end.compact.inject(:+)
-
- render('admin/apps/products')
- end
-
- def create
- @new = CheckoutProduct.new(product_post_params)
-
- if @new.save
- redirect_to(checkout_product_path(@new))
- else
- @products = CheckoutProduct.order(:category, :name).last_version
- @years = (2015..Date.today.study_year).map do |year|
- ["#{ year }-#{ year + 1 }", year]
- end.reverse
-
- render('admin/apps/products')
- end
- end
-
- def update
- @product = CheckoutProduct.find_by(id: params[:id])
-
- if @product.update(product_post_params)
- # if a new product is created redirect to it
- product = CheckoutProduct.find_by(parent: @product.id)
- prod_id = product ? product.id.to_s : @product.id.to_s
-
- redirect_to(checkout_product_path(product || @product.id, anchor: "product_#{ prod_id }"))
- else
- @years = (2015..Date.today.study_year).map do |year|
- ["#{ year }-#{ year + 1 }", year]
- end.reverse
- @products = CheckoutProduct.order(:category, :name).last_version
-
- render('admin/apps/products')
- end
- end
-
- def flip_active
- @product = CheckoutProduct.find(params[:checkout_product_id])
-
- head(:internal_server_error) unless @product.update(product_flipactive_params)
- end
-
- def change_funds
- if params[:uuid]
- card = CheckoutCard.joins(:checkout_balance).find_by(uuid: params[:uuid])
- transaction = CheckoutTransaction.new(price: params[:amount], checkout_card: card)
-
- elsif params[:member_id]
- transaction = CheckoutTransaction.new(
- price: params[:amount],
- checkout_balance: CheckoutBalance.find_by!(member_id: params[:member_id]),
- payment_method: params[:payment_method]
- )
-
- else
- render(status: :bad_request, json: I18n.t('checkout.error.identifier'))
- return
- end
-
- if transaction.save
- impressionist(transaction)
- render(status: :created, json: transaction)
- else
- render(status: :bad_request, json: {
- errors: transaction.errors
- })
- end
- end
-
- def activate_card
- card = CheckoutCard.find_by!(uuid: params[:uuid])
-
- if params[:_destroy]
- card.destroy
-
- render(status: :no_content, json: '')
- return
- end
-
- card.update(active: true)
-
- if card.save
- impressionist(card)
- render(status: :ok, json: card.to_json)
- else
- render(status: :bad_request, json: card.errors.full_messages)
- end
- end
-
- private
-
- def product_post_params
- params.require(:checkout_product).permit(:name,
- :price,
- :category,
- :active,
- :image)
- end
-
- def product_flipactive_params
- params.require(:checkout_product).permit(:active)
- end
-end
diff --git a/app/controllers/admin/home_controller.rb b/app/controllers/admin/home_controller.rb
index 376864322..e483f8836 100644
--- a/app/controllers/admin/home_controller.rb
+++ b/app/controllers/admin/home_controller.rb
@@ -7,13 +7,6 @@ def index
@activities = Activity.where("start_date >= ?", Date.to_date(Time.zone.today.study_year)).count
- @transactions = CheckoutTransaction.count(:all)
-
- @recent = CheckoutTransaction.where(
- "created_at >= ?",
- Time.zone.now.beginning_of_day
- ).order(created_at: :desc).take(12)
-
@recentactivities = Payment.where(
"created_at >= ?",
Time.zone.now.beginning_of_day
diff --git a/app/controllers/admin/logs_controller.rb b/app/controllers/admin/logs_controller.rb
new file mode 100644
index 000000000..b3bfbbef4
--- /dev/null
+++ b/app/controllers/admin/logs_controller.rb
@@ -0,0 +1,10 @@
+#:nodoc:
+class Admin::LogsController < ApplicationController
+ def index
+ @limit = params[:limit] ? params[:limit].to_i : 50
+
+ @pagination, @impressions = pagy(Impression.all.order(created_at: :desc),
+ items: params[:limit] ||= 50)
+ @total_log_items = Impression.count
+ end
+end
diff --git a/app/controllers/admin/members_controller.rb b/app/controllers/admin/members_controller.rb
index 82f3f7b06..503c8b0c1 100644
--- a/app/controllers/admin/members_controller.rb
+++ b/app/controllers/admin/members_controller.rb
@@ -43,14 +43,6 @@ def show
@years = (@member.join_date.study_year..Date.today.study_year).map do |year|
["#{ year }-#{ year + 1 }", year]
end.reverse
-
- # Pagination for checkout transactions
- @limit = params[:limit] ? params[:limit].to_i : 10
-
- @pagination, @transactions = pagy(CheckoutTransaction
- .where(checkout_balance: CheckoutBalance
- .find_by(member_id: params[:id]))
- .order(created_at: :desc), items: 10)
end
def new
@@ -147,18 +139,13 @@ def send_email
end
def destroy
- @member = Member.includes(:checkout_balance).find(params[:id])
+ @member = Member.find(params[:id])
impressionist(@member)
flash[:notice] = []
if @member.destroy
flash[:notice] << I18n.t('activerecord.errors.models.member.destroy.info', name: @member.name)
- unless @member.checkout_balance.nil?
- flash[:notice] << I18n.t('activerecord.errors.models.member.destroy.checkout_emptied',
- balance: view_context.number_to_currency(@member.checkout_balance.balance,
- unit: '€'))
- end
unless @member.mailchimp_interests.nil?
flash[:notice] << I18n.t('activerecord.errors.models.member.destroy.mailchimp_queued')
end
@@ -177,13 +164,6 @@ def payment_whatsapp
render(layout: false, content_type: "text/plain")
end
- def set_card_disabled
- @uuid = params[:uuid]
- @to = params[:to]
- @card = CheckoutCard.find_by(uuid: @uuid)
- @card.update(disabled: @to)
- end
-
private
def member_post_params
diff --git a/app/controllers/admin/payments_controller.rb b/app/controllers/admin/payments_controller.rb
index 576f4d861..2915af64c 100644
--- a/app/controllers/admin/payments_controller.rb
+++ b/app/controllers/admin/payments_controller.rb
@@ -16,15 +16,6 @@ def index
[activity, days, sent_mails]
end
- # Get checkout transactions that were purchased by pin of yesterday
- @checkout_transactions = CheckoutTransaction.where(
- 'DATE(checkout_transactions.created_at) = DATE(?) AND payment_method = \'Gepind\'', 1.day.ago
- ).order(created_at: :desc)
- @dat = @checkout_transactions.map do |x|
- { member_id: x.checkout_balance.member.id, name: x.checkout_balance.member.name, price: x.price,
- date: x.created_at.to_date }
- end.to_json
-
# Counts if the activity has debtors and if 4 weeks have passed (last friday
# is more than 21 days ago since 0 counts aswell)
@late_activities = Activity.debtors.select do |activity|
@@ -61,18 +52,6 @@ def whatsapp_redirect
redirect_to(url.to_s)
end
- def update_transactions
- checkout_transactions = CheckoutTransaction.where(
- 'DATE(checkout_transactions.created_at) = DATE(?) AND payment_method = \'Gepind\'', params[:start_date]
- ).order(created_at: :desc)
- data = checkout_transactions.map do |x|
- { member_id: x.checkout_balance.member.id, name: x.checkout_balance.member.name, price: x.price,
- date: x.created_at.to_date }
- end
-
- render(json: data)
- end
-
def export_payments
unless params[:export_type].present? && params[:start_date].present? && params[:end_date].present?
return head(:bad_request)
@@ -98,7 +77,7 @@ def export_payments
'%Y-%m-%d') }.csv")
end
format.js do
- render(js: "window.open(\"#{ transactions_export_path(
+ render(js: "window.open(\"#{ payment_transactions_export_path(
format: :csv,
start_date: params[:start_date],
end_date: params[:end_date],
diff --git a/app/controllers/admin/apps_controller.rb b/app/controllers/admin/transactions_controller.rb
similarity index 60%
rename from app/controllers/admin/apps_controller.rb
rename to app/controllers/admin/transactions_controller.rb
index f7c3fb419..dcb1d215d 100644
--- a/app/controllers/admin/apps_controller.rb
+++ b/app/controllers/admin/transactions_controller.rb
@@ -1,18 +1,6 @@
#:nodoc:
-class Admin::AppsController < ApplicationController
- def checkout
- @pagination = 5
-
- @pagination, @transactions = pagy(CheckoutTransaction.includes(:checkout_card)
- .order(created_at: :desc), items: params[:limit] ||= 20)
-
- @cards = CheckoutCard.joins(:member).select(:id, :uuid, :member_id).where(active: false)
-
- @credit = CheckoutBalance.sum(:balance)
- @products = CheckoutProduct.where(active: true).count
- end
-
- def transactions
+class Admin::TransactionsController < ApplicationController
+ def index
@transactions = Payment.order(created_at: :desc)
@transactions = @transactions.search_by_name(params[:search]) if params[:search].present?
diff --git a/app/controllers/api/checkout_controller.rb b/app/controllers/api/checkout_controller.rb
deleted file mode 100644
index 29fa77037..000000000
--- a/app/controllers/api/checkout_controller.rb
+++ /dev/null
@@ -1,144 +0,0 @@
-# Controller used for checkout before oauth was implemented
-# @deprecated controller, base controller should be replaced with oauth
-class Api::CheckoutController < ActionController::Base
- protect_from_forgery except: %i[info purchase create products recent]
- before_action :authenticate_checkout, only: %i[info purchase create products recent]
- before_action :authenticate_card, only: %i[info purchase]
-
- respond_to :json
-
- def products
- @products = CheckoutProduct.where(active: true)
- end
-
- def recent
- recent = CheckoutTransaction.joins(:checkout_card).where(
- checkout_card: CheckoutCard.where(member_id: CheckoutCard.find_by(uuid: params[:uuid]).member_id)
- ).order(created_at: :desc).limit(5)
- items = []
- recent.each do |item|
- item.items.each do |id|
- items << id
- end
- end
- products = CheckoutProduct.where(id: items).limit(5).to_a
- @products = items.map { |id| products.find { |product| product.id == id } }
- end
-
- def info
- @card = CheckoutCard.joins(:member, :checkout_balance).select(:id, :uuid, :first_name,
- :balance, :active).find_by(uuid: params[:uuid])
-
- return head(:not_found) unless @card
- end
-
- def purchase
- card = CheckoutCard.find_by!(uuid: params[:uuid])
-
- transaction = CheckoutTransaction.new(items: ahelper(params[:items]), checkout_card: card)
-
- if transaction.save!
- render(status: :created, json: {
- uuid: card.uuid,
- first_name: card.member.first_name,
- balance: card.checkout_balance.balance + transaction.price,
- created_at: transaction.created_at
- })
- else
- i18n_scope = %i[activerecord errors models checkout_transaction attributes]
-
- not_liquor_time_translation = I18n.t('items.not_liquor_time', scope: i18n_scope)
- insufficient_credit_translation = I18n.t('price.insufficient_credit', scope: i18n_scope)
-
- case transaction.errors
- when transaction.errors[:items].includes(not_liquor_time_translation)
- render(status: :not_acceptable, json: {
- message: not_liquor_time_translation
- })
- when transaction.errors[:price].includes(insufficient_credit_translation)
- render(status: :payload_too_large, json: {
- message: I18n.t(insufficient_credit_translation, scope: i18n_scope),
- balance: card.checkout_balance.balance,
- items: ahelper(params[:items]),
- costs: transaction.price
- })
- else
- render(status: :bad_request, json: {
- errors: transaction.errors
- })
- end
- end
- end
-
- def create
- head(:conflict) && return unless CheckoutCard.find_by(uuid: params[:uuid]).nil?
-
- card = CheckoutCard.new(uuid: params[:uuid],
- member: Member.find_by!(student_id: params[:student]), description: params[:description])
-
- if card.save
- card.send_confirmation!
- render(status: :created,
- json: CheckoutCard.joins(:member, :checkout_balance).select(
- :id,
- :uuid,
- :first_name,
- :balance
- ).find_by!(uuid: params[:uuid]).to_json)
- else
- head(:conflict)
- end
- end
-
- def confirm
- card = CheckoutCard.where(confirmation_token: params['confirmation_token']).first
- redirect_to(:new_user_session)
-
- if card.nil?
- flash[:alert] = I18n.t('checkout.card.nil')
- return
- end
-
- if card.active
- flash[:alert] = I18n.t('checkout.card.already_activated')
- return
- end
-
- if card.update(active: true)
- flash[:notice] = I18n.t('checkout.card.activated')
- else
- flash[:alert] = I18n.t('checkout.card.not_activated')
- end
- end
-
- private
-
- def ahelper(obj)
- return [] if obj.empty?
-
- begin
- return Array.new(1, obj.to_i) if obj.is_number?
-
- return JSON.parse(obj)
- rescue StandardError
- return []
- end
- end
-
- # TODO: implement for OAuth client credentials
- def authenticate_checkout
- if params[:token] != ENV['CHECKOUT_TOKEN']
- head(:forbidden)
- nil
- end
- end
-
- def authenticate_card
- @uuid = params[:uuid]
- @card = CheckoutCard.find_by(uuid: @uuid)
- render(status: :not_found && return) if @card.nil?
- render(status: :unauthorized, json: I18n.t('checkout.error.not_activated')) unless @card.active
- render(status: :unauthorized, json: I18n.t('checkout.error.disabled')) if @card.disabled
- (@card.active and !@card.disabled)
- end
-end
diff --git a/app/controllers/api/internal_controller.rb b/app/controllers/api/internal_controller.rb
deleted file mode 100644
index 06186ed53..000000000
--- a/app/controllers/api/internal_controller.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# Internal API controller
-class Api::InternalController < ActionController::Base
- protect_from_forgery
- before_action :authenticate_internal
- respond_to :json
-
- def member_by_studentid
- @mongoose_user = Member.select(:id, :first_name, :infix, :last_name, :birth_date,
- :email).find_by(student_id: params[:student_number])
- return head(:no_content) unless @mongoose_user
- end
-
- def member_by_id
- @mongoose_user = Member.select(:id, :first_name, :infix, :last_name,
- :birth_date).find(params[:id])
- return head(:no_content) unless @mongoose_user
- end
-
- def authenticate_internal
- return unless request.headers['Authorization'] != ENV['CHECKOUT_TOKEN']
-
- head(:forbidden)
- nil
- end
-
- def authenticate_card
- @uuid = params[:uuid]
- @card = CheckoutCard.find_by(uuid: @uuid)
- render(status: :not_found && return) if @card.nil?
- render(status: :unauthorized, json: I18n.t('checkout.error.not_activated')) unless @card.active
- render(status: :unauthorized, json: I18n.t('checkout.error.disabled')) if @card.disabled
- (@card.active and !@card.disabled)
- end
-end
diff --git a/app/controllers/members/home_controller.rb b/app/controllers/members/home_controller.rb
index 009365125..a68b9c57a 100644
--- a/app/controllers/members/home_controller.rb
+++ b/app/controllers/members/home_controller.rb
@@ -8,8 +8,6 @@ class Members::HomeController < ApplicationController
def index
@member = Member.find(current_user.credentials_id)
- # information of the middlebar
- @balance = CheckoutBalance.find_by(member_id: current_user.credentials_id)
@debt = Participant
.where(paid: false, member: @member, reservist: false)
.joins(:activity)
@@ -34,13 +32,6 @@ def index
.joins(:participants)
.where(participants: { member: @member, reservist: false })
.order('start_date DESC')
-
- @transactions = CheckoutTransaction.where(
- checkout_balance: CheckoutBalance.find_by(
- member_id: current_user.credentials_id
- )
- ).order(created_at: :desc).limit(10) # ParticipantTransaction.all #
- @transaction_costs = Settings.mongoose_ideal_costs
end
def edit
@@ -85,9 +76,6 @@ def update
def download
@member = Member.includes(:activities, :groups, :educations).find(current_user.credentials_id)
- @transactions = CheckoutTransaction.where(
- checkout_balance: CheckoutBalance.find_by(member_id: current_user.credentials_id)
- ).order(created_at: :desc)
send_data(render_to_string(layout: false),
filename: "#{ @member.name.downcase.tr(' ', '-') }.html",
diff --git a/app/controllers/members/payments_controller.rb b/app/controllers/members/payments_controller.rb
index 04238f40a..746e1c743 100644
--- a/app/controllers/members/payments_controller.rb
+++ b/app/controllers/members/payments_controller.rb
@@ -7,12 +7,6 @@ class Members::PaymentsController < ApplicationController
def index
@member = Member.find(current_user.credentials_id)
@participants = @member.unpaid_activities
- @transactions = CheckoutTransaction.where(
- checkout_balance: CheckoutBalance.find_by(
- member_id: current_user.credentials_id
- )
- ).order(created_at: :desc).limit(10) # ParticipantTransaction.all #
- @transaction_costs = Settings.mongoose_ideal_costs
end
def pay_activities
@@ -75,43 +69,6 @@ def self.join_with_char_limit(collection, separator, maxlength)
return ".. & #{ collection.length } meer"
end
- def add_funds
- member = Member.find(current_user.credentials_id)
- balance = CheckoutBalance.find_or_create_by!(member: member)
- description = I18n.t('activerecord.errors.models.payment.attributes.checkout')
- amount = transaction_params[:amount].gsub(",", ".").to_f
-
- if amount < 1
- flash[:warning] = I18n.t('failed', scope: 'activerecord.errors.models.payment')
- redirect_to(member_payments_path)
- return
- end
-
- if balance.nil?
- flash[:warning] = I18n.t('failed', scope: 'activerecord.errors.models.payment')
- redirect_to(member_payments_path)
- return
- end
-
- payment = Payment.new(
- description: description,
- amount: amount,
- member: member,
- issuer: transaction_params[:bank],
- payment_type: :ideal,
-
- transaction_id: nil,
- transaction_type: :checkout,
- redirect_uri: member_payments_path
- )
- if payment.save
- redirect_to(payment.payment_uri)
- else
- flash[:warning] = I18n.t('failed', scope: 'activerecord.errors.models.payment')
- redirect_to(members_home_path)
- end
- end
-
private
def transaction_params
diff --git a/app/controllers/public/status_controller.rb b/app/controllers/public/status_controller.rb
index d0d76e565..6594e2baf 100644
--- a/app/controllers/public/status_controller.rb
+++ b/app/controllers/public/status_controller.rb
@@ -48,7 +48,7 @@ def update
def destroy
@token = Token.find_by!(token: params[:token], intent: :consent)
- @member = Member.includes(:checkout_balance).find(@token.object.id)
+ @member = Member.find(@token.object.id)
impressionist(@member)
flash[:notice] = []
@@ -59,11 +59,6 @@ def destroy
if @member.destroy
@token.destroy
flash[:notice] << I18n.t('activerecord.errors.models.member.destroy.info', name: @member.name)
- unless @member.checkout_balance.nil?
- flash[:notice] << I18n.t('activerecord.errors.models.member.destroy.checkout_emptied',
- balance: view_context.number_to_currency(@member.checkout_balance.balance,
- unit: '€'))
- end
flash[:notice] << I18n.t('activerecord.errors.models.member.destroy.mailchimp_queued')
redirect_to(users_root_url)
diff --git a/app/javascript/application.js b/app/javascript/application.js
index 33655b821..94a13e051 100644
--- a/app/javascript/application.js
+++ b/app/javascript/application.js
@@ -24,7 +24,6 @@ import "../../vendor/assets/javascripts/bootstrap-file-input";
import "./src/lib/dropdown";
import "./src/lib/editor";
import "./src/lib/mail";
-import "./src/admin/index.js";
import "./src/language.js";
-import "./src/application.js";
+import "./src/admin/index.js";
import "./src/admin/datepicker";
diff --git a/app/javascript/src/admin/apps.js b/app/javascript/src/admin/apps.js
deleted file mode 100644
index 1b1acf6f9..000000000
--- a/app/javascript/src/admin/apps.js
+++ /dev/null
@@ -1,305 +0,0 @@
-//
-//= require bootstrap-file-input
-import $ from "jquery";
-import I18n from "../translations.js";
-import toastr from "toastr";
-
-$(document).on("ready page:load turbolinks:load", function () {
- bind_flip();
- $(document).on("click", ".allow-focus", function (e) {
- e.stopPropagation();
- });
-
- $('form .input-group-btn .file-input-wrapper input[type="file"]').on(
- "change",
- function () {
- if (this.files && this.files[0]) {
- $("form .input-group input#output").val(this.files[0].name);
- }
- },
- );
-
- // activate card
- $("div#cards ul.list-group .btn-group button:nth-child(1)").bind(
- "click",
- function () {
- var button = $(this);
- var row = $(this).closest(".list-group-item");
- var token = encodeURIComponent(
- $(this).closest(".page").attr("data-authenticity-token"),
- );
-
- $(button).attr("disabled", "disabled");
-
- $.ajax({
- url: "/apps/cards",
- type: "PATCH",
- data: {
- uuid: $(row).attr("data-uuid"),
- authenticity_token: token,
- },
- })
- .done(function () {
- toastr.success(I18n.t("checkout.card.activated"));
- $(row).remove();
- })
- .fail(function () {
- toastr.error(I18n.t("checkout.card.not_activated"));
- $(button).removeAttr("disabled");
- });
- },
- );
-
- $("div#cards ul.list-group .btn-group button:nth-child(2)").bind(
- "click",
- function () {
- var button = $(this);
- var row = $(this).closest(".list-group-item");
- var token = encodeURIComponent(
- $(this).closest(".page").attr("data-authenticity-token"),
- );
-
- $(button).attr("disabled", "disabled");
-
- $.ajax({
- url: "/apps/cards",
- type: "PATCH",
- data: {
- uuid: $(row).attr("data-uuid"),
- authenticity_token: token,
- _destroy: true,
- },
- })
- .done(function () {
- toastr.warning(I18n.t("checkout.card.removed"));
- $(row).remove();
- })
- .fail(function () {
- toastr.error(I18n.t("checkout.card.not_removed"));
- $(button).removeAttr("disabled");
- });
- },
- );
-
- var credit = $("#credit");
- // search members using dropdown
- var cardHolder = credit.find("input#card_holder");
- var amountInput = credit.find(".form-group input#amount");
- var paymentMethodInput = credit.find("select#payment_method");
- cardHolder.search().on("selected", function (event, id, name) {
- $(this).attr("disabled", "disabled").val(name);
- credit
- .find(".form-group#search_card")
- .attr("data-id", id)
- .removeClass("col-md-12")
- .addClass("col-md-4");
-
- credit.find(".form-group").css("display", "block");
- amountInput.focus();
- });
-
- // catch [ESC] to cancel
- amountInput.on("keyup", function (event, code) {
- if (event.keyCode === 27 || code === 27) {
- credit
- .find(".form-group#search_card input")
- .removeAttr("disabled")
- .val("");
- credit.find(".form-group:not(#search_card)").css("display", "none");
- credit
- .find(".form-group#search_card")
- .removeAttr("data-id")
- .removeClass("col-md-4")
- .addClass("col-md-12");
- cardHolder.focus();
- $(this).val("");
- }
- });
-
- // after member is selected, set an amount
- credit.find("form.form-inline").on("submit", function (event) {
- var token = encodeURIComponent(
- $(this).closest(".page").attr("data-authenticity-token"),
- );
-
- event.preventDefault();
- if (amountInput.prop("disabled")) return;
-
- if (!amountInput.val()) {
- toastr.error(I18n.t("admin.members.top_up_error"));
- return;
- }
-
- var price = amountInput.val();
-
- // Make it a bit more pretty
- if (!isNaN(price)) $(this).val(parseFloat(price).toFixed(2));
-
- amountInput.prop("disabled", true);
-
- $.ajax({
- url: "/apps/transactions",
- type: "PATCH",
- data: {
- member_id: credit.find(".form-group#search_card").attr("data-id"),
- amount: price,
- payment_method: paymentMethodInput.val(),
- authenticity_token: token,
- },
- })
- .done(function (data) {
- amountInput.prop("disabled", false);
- toastr.success(I18n.t("admin.members.top_up"));
-
- //toevoegen aan de lijst
- $("#transactions").trigger("transaction_added", data); //TODO
-
- //formulier terugveranderen
- amountInput.trigger("keyup", [27]);
-
- //Reset select (payment_method)
- paymentMethodInput.val("");
- })
- .fail(function (data) {
- amountInput.prop("disabled", false);
-
- if (data.status === 404)
- toastr.error(I18n.t("checkout.card.not_found"));
-
- if (data.status === 413) toastr.error(data.responseText, data.status);
-
- if (data.status === 400) toastr.error(I18n.t("checkout.error.numeric"));
- });
- });
-
- // [DELETE] checkout_product
- $("#products button.destroy").on("click", function () {
- var id = $(this).closest("tr").attr("data-id");
- var token = encodeURIComponent(
- $(this).closest(".page").attr("data-authenticity-token"),
- );
- var row = $(this).closest("tr");
-
- if (
- !confirm(
- I18n.t("admin.general.remove", { user: $(row).find("a").html() }),
- )
- )
- return;
-
- $.ajax({
- url: "/apps/products",
- type: "DELETE",
- data: {
- id: id,
- authenticity_token: token,
- },
- })
- .done(function () {
- toastr.warning(
- `${$(row).find("a").html()} ${I18n.t("admin.general.removed")}`,
- );
- $(row).remove();
- })
- .fail(function (error) {
- toastr.error(error.statusText, error.status);
- });
- });
-
- $(".date-input input").on("change", function () {
- var params = {};
-
- params.date = $(this).val();
- location.search = $.param(params);
- });
-
- $("form").on("submit", function () {
- $(this).find('button[type="submit"].wait').addClass("disabled");
- });
-});
-
-function bind_flip() {
- //Reset all event handlers
- $("#products button").off("click");
-
- $("#products").find("button.activate").on("click", product.activate);
-
- $("#products").find("button.deactivate").on("click", product.deactivate);
-}
-
-var product = {
- deactivate: function () {
- var row = $(this).closest("tr");
-
- $.ajax({
- url: "/apps/products/" + row.attr("data-id") + "/flip",
- type: "PATCH",
- data: {
- checkout_product: {
- active: false,
- },
- },
- })
- .done(function () {
- toastr.success(
- `${$(row).find("a").html()} ${I18n.t(
- "checkout.products.deactivated",
- )}`,
- );
-
- $(row)
- .addClass("inactive")
- .find("button.deactivate")
- .empty()
- .removeClass("deactivate btn-warning")
- .addClass("activate btn-primary")
- .append(
- ` ${I18n.t(
- "checkout.products.deactivate",
- )}`,
- );
-
- //Reset all event handlers
- bind_flip();
- })
- .fail(function (error) {
- toastr.error(error.statusText, error.status);
- });
- },
-
- activate: function () {
- var row = $(this).closest("tr");
-
- $.ajax({
- url: "/apps/products/" + row.attr("data-id") + "/flip",
- type: "PATCH",
- data: {
- checkout_product: {
- active: true,
- },
- },
- })
- .done(function () {
- toastr.success(
- `${$(row).find("a").html()} ${I18n.t("checkout.products.activated")}`,
- );
-
- $(row)
- .removeClass("inactive")
- .find("button.activate")
- .empty()
- .removeClass("activate btn-primary inactive")
- .addClass("deactivate btn-warning")
- .append(
- ` ${I18n.t(
- "checkout.products.activate",
- )}`,
- );
-
- bind_flip();
- })
- .fail(function (error) {
- toastr.error(error.statusText, error.status);
- });
- },
-};
diff --git a/app/javascript/src/admin/index.js b/app/javascript/src/admin/index.js
index 15bbaea2c..be7ebf7f4 100644
--- a/app/javascript/src/admin/index.js
+++ b/app/javascript/src/admin/index.js
@@ -1,5 +1,4 @@
import "./activities.js";
-import "./apps.js";
import "./editor.js";
import "./groups.js";
import "./main.js";
diff --git a/app/javascript/src/admin/members.js b/app/javascript/src/admin/members.js
index 88ce86d75..e2062250d 100644
--- a/app/javascript/src/admin/members.js
+++ b/app/javascript/src/admin/members.js
@@ -132,155 +132,4 @@ $(document).on("ready page:load turbolinks:load", function () {
}
});
}
-
- // after member is selected, set an amount
- var creditInputGroup = $("#credit.input-group");
- var inputAmount = creditInputGroup.find("input#amount");
- var paymentMethodInput = creditInputGroup.find("select#payment_method");
- creditInputGroup.find("#upgrade-btn").on("click", function () {
- var token = encodeURIComponent(
- $(this).closest(".page").attr("data-authenticity-token"),
- );
-
- if (!inputAmount.val()) {
- toastr.error(I18n.t("admin.members.top_up_error"));
- return;
- }
-
- if (inputAmount.prop("disabled")) return;
-
- var price = $(inputAmount).val();
-
- // Make it a bit more pretty
- if (!isNaN(price)) $(this).val(parseFloat(price).toFixed(2));
-
- inputAmount.prop("disabled", true);
-
- $.ajax({
- url: "/apps/transactions",
- type: "PATCH",
- data: {
- member_id: creditInputGroup.attr("data-member-id"),
- amount: price,
- payment_method: paymentMethodInput.val(),
- authenticity_token: token,
- },
- })
- .done(function (data) {
- inputAmount.prop("disabled", false);
- toastr.success(I18n.t("admin.members.top_up"));
-
- //toevoegen aan de lijst
- $("#transactions").trigger("transaction_added", data); //TODO
-
- //remove from input and select
- paymentMethodInput.val("");
- inputAmount.val("");
- })
- .fail(function (data) {
- inputAmount.prop("disabled", false);
-
- if (!data.responseJSON) {
- toastr.error(data.statusText, data.status);
- return;
- }
-
- let errors = data.responseJSON.errors;
- let text = "";
- for (let attribute in errors) {
- for (let error of errors[attribute]) text += error + ", ";
-
- // remove last colon and space
- text = text.slice(0, -2);
- text += "
";
- }
- // remove last line break
- text = text.slice(0, -5);
-
- toastr.error(text);
- });
- });
-
- destroy(null);
-
- $("#memberscards button").on("click", button_action);
-
- function button_action() {
- let row = $(this).closest("tr");
- let status = $(row).children(".cardstatus");
- let uuid = row.attr("data-uuid");
- let memberid = row.attr("data-member-id");
- let token = encodeURIComponent(
- $(this).closest(".page").attr("data-authenticity-token"),
- );
-
- let tobeactivated = row.attr("data-active") == 0;
- let disabled = row.attr("data-disabled") == 1;
-
- let entry =
- "admin.cards." +
- (tobeactivated ? "" : disabled ? "re" : "de") +
- "activate_confirm";
- if (!confirm(I18n.t(entry, { uuid: uuid }))) return;
-
- let url = tobeactivated
- ? "/apps/cards"
- : "/members/" + memberid + "/set_card_disabled/" + uuid;
- let successmsg = tobeactivated
- ? I18n.t("checkout.card.activated")
- : disabled
- ? I18n.t("admin.cards.activate_success", { uuid: uuid })
- : I18n.t("admin.cards.deactivate_success", { uuid: uuid });
-
- $.ajax({
- url: url,
- type: "PATCH",
- data: {
- authenticity_token: token,
- uuid: uuid, // only needed for 'to be activated',
- to: !disabled, // only needed for toggling 'disabled'
- },
- })
- .done(() => {
- // Remove current classes
- if (tobeactivated) {
- status.removeClass("text-info");
- $(this).removeClass("activate btn-primary");
- row.attr("data-active", 1);
- } else if (disabled) {
- status.removeClass("text-muted");
- $(this).removeClass("reactivate btn-warning");
- } else {
- $(this).removeClass("deacticate btn-danger");
- }
- // Add new classes & content
- if (disabled ^ tobeactivated) {
- status.empty().append(I18n.t("admin.cards.active"));
- $(this)
- .empty()
- .append(
- '' + I18n.t("admin.cards.deactivate"),
- )
- .addClass("deactivate btn-danger");
- row.attr("data-disabled", 0);
- } else {
- status
- .empty()
- .append(I18n.t("admin.cards.deactivated"))
- .addClass("text-muted");
- $(this)
- .empty()
- .append(
- '' +
- I18n.t("admin.cards.reactivate"),
- )
- .addClass("reactivate btn-warning");
- row.attr("data-disabled", 1);
- }
- toastr.success(successmsg);
- })
- .fail((e) => {
- toastr.error(e.statusText, e.status);
- });
- }
});
diff --git a/app/javascript/src/admin/payments.js b/app/javascript/src/admin/payments.js
index 3b51a0a25..e0be6b6ae 100644
--- a/app/javascript/src/admin/payments.js
+++ b/app/javascript/src/admin/payments.js
@@ -18,13 +18,6 @@ $(document).on("ready page:load turbolinks:load", function () {
},
);
- $(".input-group#transaction_dates #update_transactions button").bind(
- "click",
- function () {
- getCheckoutTransactions($(this));
- },
- );
-
//Update search
$("input#search").on("keyup", function () {
var query = new RegExp($(this).val(), "i");
@@ -63,61 +56,3 @@ function getWhatsappText(url) {
async: false,
}).responseText;
}
-
-//Requests all checkout transactions for a given date
-function getCheckoutTransactions(button) {
- var start_date = $("#pin-total-date").val();
-
- $.ajax({
- url: "/payments/transactions",
- type: "GET",
- data: {
- start_date: start_date,
- },
- })
- .done(function (data, status) {
- //Find and clear table
- var table = $("#transactions").find("tbody");
- var total = 0.0;
- $(table).find("tr").remove();
-
- // Bind json data to copy button
- $("#copy_transactions button").attr(
- "data-clipboard-text",
- JSON.stringify(data),
- );
-
- //Fill table if not empty
- if (data.length == 0) {
- table.append(
- `
-GET /api/checkout/products HTTP/1.1 -Host → koala.svsticky.nl - -+ token :string (required) -- -```json -HTTP/1.1 200 OK -Content-Type → application/json; charset=utf-8 - -[ - { - "id": 98, - "name": "7up", - "category": 1, - "price": "0.4", - "image": "https://koala.svsticky.nl/images/checkout_products/7/original.png?1433681363" - }, - { - "id": 100, - "name": "Coca Cola regular", - "category": 1, - "price": "0.53", - "image": "https://koala.svsticky.nl/images/checkout_products/1/original.png?1433681225" - } -] -``` - - - -##### Information for card -
-GET /api/checkout/card HTTP/1.1 -Host → koala.svsticky.nl - -+ token :string (required) -+ uuid :string (required) - unique identifier of the OV-card -- -```json -HTTP/1.1 200 OK -Content-Type → application/json; charset=utf-8 - -{ - "id": 9, - "uuid": "EDD411C4", - "first_name": "Martijn", - "balance": "4.15" -} -``` - -```json -# card with that specific uuid not found -HTTP/1.1 404 NOT FOUND -Content-Type → application/json; charset=utf-8 -``` - - - -##### Create a new card and add to member -
-POST /api/checkout/card HTTP/1.1 -Host → koala.svsticky.nl - -+ token :string (required) -+ student :string (required) - student id as known by koala -+ uuid :string (required) -+ description :string -- -```json -HTTP/1.1 201 CREATED -Content-Type → application/json; charset=utf-8 - -{ - "id": 9, - "uuid": "EDD411C4", - "first_name": "Martijn", - "balance": "0.0" -} -``` - -```json -# Student could not be found, make sure the student id is correct -HTTP/1.1 404 NOT FOUND -Content-Type → application/json; charset=utf-8 -``` - -```json -# This uuid is already registered to some student -HTTP/1.1 409 CONFLICT -Content-Type → application/json; charset=utf-8 -``` - - - -##### Create a new transaction -
-POST /api/checkout/transaction HTTP/1.1 -Host → koala.svsticky.nl - -+ token :string (required) -+ uuid :string (required) -+ items :array (required) - array with item ids -- -```json -HTTP/1.1 201 CREATED -Content-Type → application/json; charset=utf-8 - -{ - "uuid": "EDD411C4", - "first_name": "Martijn", - "balance": "0.9", - "created_at": "2016-02-06T10:33:50.382+01:00" -} -``` - -```json -# Card is not yet activated -HTTP/1.1 401 UNAUTHORIZED -Content-Type → application/json; charset=utf-8 -``` - -```json -# One of the items in your array is not found or -# there is no card with the specified uuid -HTTP/1.1 404 NOT FOUND -Content-Type → application/json; charset=utf-8 -``` - -```json -HTTP/1.1 413 REQUEST ENTITY TOO LARGE -Content-Type → application/json; charset=utf-8 - -{ - "message": "insufficient funds", - "balance": "2.9", - "items": [ - 1, - 2, - 2 - ], - "costs": "-4.6" -} -``` - -```json -# Not allowed to buy alcohol at the moment -HTTP/1.1 406 NOT ACCEPTABLE -Content-Type → application/json; charset=utf-8 - -{ - "message": "alcohol allowed at 16:00" -} -``` +## Participant \ No newline at end of file