Skip to content

Commit

Permalink
Completly remove word action from this project
Browse files Browse the repository at this point in the history
  • Loading branch information
hmlON committed Jul 23, 2017
1 parent de02daa commit a6865be
Show file tree
Hide file tree
Showing 21 changed files with 42 additions and 185 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[![Build Status](https://semaphoreci.com/api/v1/hmlon/room538/branches/master/shields_badge.svg)](https://semaphoreci.com/hmlon/room538)
# Room538
A hostel room control application. It is destined for controlling who is next on things like "cleaning up", "taking out trash" or other actions between you and your roommates.
A hostel room control application. It is destined for controlling who is next on things like "cleaning up", "taking out trash" or other activities between you and your roommates.

Deployed to Heroku: https://room538.herokuapp.com/

### Features
- Authentication via registration or VK
- Create rooms and invite your roommates in them
- Create new actions and use them in your room
- Create new activities and use them in your room
- Simple dashboard with:
- Status: who is next on what actions
- Progress: progresses on every action of every roommate
- History: history of submitting done actions in your room
- Status: who is next on what activities
- Progress: progresses on every activity of every roommate
- History: history of submitting done activities in your room
- Ability to reset room progress, edit or leave room

### Technologies:
Expand Down
2 changes: 0 additions & 2 deletions app/assets/stylesheets/actions.sass

This file was deleted.

1 change: 0 additions & 1 deletion app/assets/stylesheets/application.sass
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@
@import "forms"
@import "history"
@import "users"
@import "actions"
16 changes: 8 additions & 8 deletions app/controllers/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ def index
end

def punish
action = Action.find_by(name: 'taking out trash')
room_action = RoomAction.find_by(action_id: action.id)
users = User.where(id: params[:punishment][:user_ids].drop(1))
# action = Action.find_by(name: 'taking out trash')
# room_action = RoomAction.find_by(action_id: action.id)
# users = User.where(id: params[:punishment][:user_ids].drop(1))

users.each do |user|
user_action = user.user_actions.find_by(room_action_id: room_action.id)
user_action.update(value: user_action.value - 1)
# create_punishment
end
# users.each do |user|
# user_action = user.user_actions.find_by(room_action_id: room_action.id)
# user_action.update(value: user_action.value - 1)
# # create_punishment
# end

redirect_to dashboard_path, notice: 'Roommates are successfully punished.'
end
Expand Down
5 changes: 2 additions & 3 deletions app/controllers/room_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ def index
end

def accept
sender = User.find(@request.sender_id)
sender.join_room(current_user.room)
redirect_to dashboard_path, notice: "#{sender.name} successfully joined your room."
current_user.room.users << @request.sender
redirect_to dashboard_path, notice: "#{@request.sender.name} successfully joined your room."
end

def create
Expand Down
17 changes: 6 additions & 11 deletions app/controllers/rooms_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class RoomsController < ApplicationController
before_action :authenticate_user!, except: [:join]
before_action :require_room_presence, only: [:edit, :update, :destroy]
before_action :require_room_presence, only: [:edit, :update, :destroy, :leave, :reset_progress]
before_action :require_room_absence, only: [:new, :create]

def index
Expand All @@ -24,13 +24,11 @@ def create
end

def edit
# ids = current_user.room.user_ids
# ids << nil # add default actions
@room_activities = @room.room_activities.unscoped # Action.where(creator_id: ids)
@room_activities = @room.room_activities.unscoped
end

def update
if @room.update(room_params) # RoomUpdater.new(@room, room_params).update
if @room.update(room_params)
redirect_to dashboard_path, notice: 'You have successfully updated your room.'
else
render :edit
Expand All @@ -46,8 +44,8 @@ def join
return redirect_to edit_room_path,
notice: 'To join another room you need to leave your current. You can do this in danger zone.'
end
room = Room.all.select { |room_s| room_s.invite_token == params[:token] }.first
current_user.join_room(room)
room = Room.with_invite_token(params[:token])
room.users << current_user
redirect_to dashboard_path, notice: "Welcome to room \"#{room.name}\"!"
end

Expand All @@ -59,10 +57,7 @@ def leave
end

def reset_progress
room = current_user.room
room.room_actions.flat_map(&:user_actions).each do |user_action|
user_action.update(value: 0)
end
@room.activities.destroy_all

redirect_to dashboard_path, notice: 'Resetted room progress successfully.'
end
Expand Down
15 changes: 0 additions & 15 deletions app/models/action.rb

This file was deleted.

8 changes: 5 additions & 3 deletions app/models/room.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# A hostel room is a place where users who live in that room do actions like
# A room is a place where users who live in that room do activities like
# 'taking out trash' with their roommates
class Room < ApplicationRecord
has_many :users
has_many :room_activities, dependent: :destroy
has_many :room_actions, dependent: :destroy
has_many :actions, through: :room_actions
has_many :room_requests, dependent: :destroy

validates :name, presence: true
Expand All @@ -19,6 +17,10 @@ def create_default_room_activities
end
end

def self.with_invite_token(token)
all.find { |room_s| room_s.invite_token == token }
end

def invite_url
Rails.application.routes.url_helpers.join_room_url(token: invite_token, host: 'room538.herokuapp.com')
end
Expand Down
30 changes: 0 additions & 30 deletions app/models/room_action.rb

This file was deleted.

12 changes: 1 addition & 11 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
class User < ApplicationRecord
belongs_to :room, optional: true
has_many :activities
has_many :user_actions
has_many :sent_room_requests, class_name: 'RoomRequest', foreign_key: 'sender_id'
has_many :created_actions, class_name: 'Action', foreign_key: 'creator_id'

default_scope { order(:id) }

Expand All @@ -20,16 +18,8 @@ def next_on_room_activities
room_activities.select { |room_activity| room_activity.next_on_user == self }
end

def join_room(room)
room.users << self
room.room_actions.each do |room_action|
user_actions.create(room_action: room_action)
end
sent_room_requests.destroy_all
end

def leave_room
user_actions.destroy_all
activities.destroy_all
update(room: nil)
end

Expand Down
9 changes: 0 additions & 9 deletions app/models/user_action.rb

This file was deleted.

4 changes: 2 additions & 2 deletions app/models/user_activity.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# User activities are actions that count of how many times user has done
# some activity
# User activity is counter of how many times user has done
# certain activity
class UserActivity
attr_reader :user, :room_activity

Expand Down
31 changes: 0 additions & 31 deletions app/services/room_updater.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/dashboard/_history.html.slim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.history-wrapper
- if @activities.empty?
.no-activities There is nothing done yet. Try sumbitting done action.
.no-activities There is nothing done yet. Try sumbitting done activity.
- @activities.each do |activity|
.activity.card.card-inverse.card-info
.card-block
Expand Down
2 changes: 1 addition & 1 deletion app/views/dashboard/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ul.nav.nav-tabs.justify-content-center.m-3 role="tablist"
#status.tab-pane.active role="tabpanel"
= render 'status'

= render 'submit_done_action_form'
= render 'submit_done_activity_form'

#progress.tab-pane role="tabpanel"
= render 'progress'
Expand Down
10 changes: 10 additions & 0 deletions db/migrate/20170723180655_drop_all_actions_tables.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class DropAllActionsTables < ActiveRecord::Migration[5.0]
def up
drop_table :user_actions
drop_table :room_actions
drop_table :actions
end

def down
end
end
30 changes: 1 addition & 29 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,11 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20170723094449) do
ActiveRecord::Schema.define(version: 20170723180655) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

create_table "actions", force: :cascade do |t|
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "creator_id"
end

create_table "activities", force: :cascade do |t|
t.integer "user_id"
t.integer "room_activity_id"
Expand All @@ -31,13 +24,6 @@
t.index ["user_id"], name: "index_activities_on_user_id", using: :btree
end

create_table "room_actions", force: :cascade do |t|
t.integer "room_id"
t.integer "action_id"
t.index ["action_id"], name: "index_room_actions_on_action_id", using: :btree
t.index ["room_id"], name: "index_room_actions_on_room_id", using: :btree
end

create_table "room_activities", force: :cascade do |t|
t.string "name"
t.integer "room_id"
Expand All @@ -61,16 +47,6 @@
t.datetime "updated_at", null: false
end

create_table "user_actions", force: :cascade do |t|
t.integer "user_id"
t.integer "room_action_id"
t.integer "value", default: 0
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["room_action_id"], name: "index_user_actions_on_room_action_id", using: :btree
t.index ["user_id"], name: "index_user_actions_on_user_id", using: :btree
end

create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "name", default: "", null: false
Expand All @@ -96,11 +72,7 @@

add_foreign_key "activities", "room_activities"
add_foreign_key "activities", "users"
add_foreign_key "room_actions", "actions"
add_foreign_key "room_actions", "rooms"
add_foreign_key "room_activities", "rooms"
add_foreign_key "room_requests", "rooms"
add_foreign_key "user_actions", "room_actions"
add_foreign_key "user_actions", "users"
add_foreign_key "users", "rooms"
end
5 changes: 0 additions & 5 deletions spec/factories/actions.rb

This file was deleted.

13 changes: 0 additions & 13 deletions spec/factories/rooms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,5 @@
end
end
end

# trait :with_old_setup do
# after :build do |room|
# room.actions << create_list(:action, 3)
# create(:user).join_room(room)
# end
# end

factory :room_with_users do
after :build do |room|
3.times { create(:user).join_room(room) }
end
end
end
end
5 changes: 0 additions & 5 deletions spec/models/action_spec.rb

This file was deleted.

0 comments on commit a6865be

Please sign in to comment.