mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-04-14 19:47:03 +00:00
Removing rewards controller, views, routes (keeping model for now
because of migration bug)
This commit is contained in:
parent
595562b762
commit
851628d200
6 changed files with 0 additions and 129 deletions
|
|
@ -1,83 +0,0 @@
|
|||
class RewardsController < ApplicationController
|
||||
|
||||
# GET /rewards/new
|
||||
# GET /rewards/new.json
|
||||
def new
|
||||
@reward = Reward.new
|
||||
@reward.user_id = current_user.id
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @reward }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /rewards/1/edit
|
||||
def edit
|
||||
@reward = current_user.rewards.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /rewards
|
||||
# POST /rewards.json
|
||||
def create
|
||||
@reward = Reward.new(params[:reward])
|
||||
@reward.user_id = current_user.id
|
||||
|
||||
respond_to do |format|
|
||||
if @reward.save
|
||||
format.html { redirect_to habits_url, notice: 'Reward was successfully created.' }
|
||||
format.json { render json: @reward, status: :created, location: @reward }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @reward.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /rewards/1
|
||||
# PUT /rewards/1.json
|
||||
def update
|
||||
@reward = current_user.rewards.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @reward.update_attributes(params[:reward])
|
||||
format.html { redirect_to habits_url, notice: 'Reward was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: @reward.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /rewards/1
|
||||
# DELETE /rewards/1.json
|
||||
def destroy
|
||||
@reward = current_user.reward.find(params[:id])
|
||||
@reward.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to habits_url }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def buy
|
||||
@reward = current_user.rewards.find(params[:id])
|
||||
@too_expensive = true
|
||||
if current_user.money > @reward.value
|
||||
current_user.money -= @reward.value
|
||||
current_user.save
|
||||
@too_expensive = false
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
# format.html { render action: "edit" }
|
||||
# format.json { render json: @habit.errors, status: :unprocessable_entity }
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
<%= form_for(@reward) do |f| %>
|
||||
<% if @reward.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@reward.errors.count, "error") %> prohibited this reward from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% @reward.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :name %><br />
|
||||
<%= f.text_field :name %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :value %><br />
|
||||
<%= f.number_field :value %>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<% if @too_expensive %>
|
||||
$('#money').effect("pulsate", 100);
|
||||
<% else %>
|
||||
$('#money').replaceWith("<%= escape_javascript(render 'shared/money') %>");
|
||||
<% end %>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<h1>Editing reward</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', habits_path %>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<h1>New reward</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', habits_path %>
|
||||
|
|
@ -8,12 +8,6 @@ HabitTracker::Application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
resources :rewards do
|
||||
member do
|
||||
get 'buy'
|
||||
end
|
||||
end
|
||||
|
||||
devise_for :users
|
||||
|
||||
# The priority is based upon order of creation:
|
||||
|
|
|
|||
Loading…
Reference in a new issue