Skip to content

Commit

Permalink
Makes some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorChalenko committed Jun 1, 2021
1 parent b6b660a commit 0c6d9de
Show file tree
Hide file tree
Showing 15 changed files with 1,016 additions and 2,700 deletions.
3 changes: 0 additions & 3 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,3 @@
*= require_tree .
*= require_self
*/
.hidden {
display: none !important;
}
2 changes: 1 addition & 1 deletion app/controllers/polls_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class PollsController < ApplicationController
def new
authorize! Poll, to: :create?
@poll = current_user.own_polls.new
@poll = Poll.new
end
end
4 changes: 2 additions & 2 deletions app/models/poll_membership.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class PollMembership < ApplicationRecord
belongs_to :user, foreign_key: 'user_id'
belongs_to :poll, foreign_key: 'poll_id'
belongs_to :user
belongs_to :poll
end
2 changes: 1 addition & 1 deletion app/views/pages/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="container-fluid" style="padding-top: 45px;">
<div class="d-flex flex-row justify-content-between align-items-center">
<h1>All poll</h1>
<%= button_to '+ New Poll', poll_new_path, method: :get, class: "btn btn-primary"%>
<%= link_to '+ New Poll', new_poll_path, class: "btn btn-primary"%>
</div>
<div class="row">
<div class="card">
Expand Down
32 changes: 18 additions & 14 deletions app/views/polls/_poll_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,43 +1,47 @@
<%= form_with model: @poll, url: poll_new_path, method: :post, class: "border rounded p-4 mt-5" do |poll| %>
<%= form_for :poll, url: new_poll_path, method: :post, class: "border rounded p-4 mt-5" do |f| %>
<div class="mb-3">
<%= poll.text_field :title, placeholder: "Title", class: "form-control" %>
<%= f.text_field :title, placeholder: "Title", class: "form-control" %>
</div>
<div class="mb-3">
<%= poll.text_area :description, placeholder: "Description", class: "form-control" %>
<%= f.text_area :description, placeholder: "Description", class: "form-control" %>
</div>
<div class="row">
<div class="col-6 mb-3 d-flex flex-column">
<%= poll.label :start_date, class: "form-label"%>
<%= poll.date_field :start_date, placeholder: "Start date", class: "form-control"%>
<%= f.label :start_date, class: "form-label"%>
<%= f.date_field :start_date, placeholder: "Start date", class: "form-control"%>
</div>
<div class="col-6 mb-3 d-flex flex-column">
<%= poll.label :end_date, class: "form-label"%>
<%= poll.date_field :end_date, placeholder: "End date", class: "form-control"%>
<%= f.label :end_date, class: "form-label"%>
<%= f.date_field :end_date, placeholder: "End date", class: "form-control"%>
</div>
</div>
<div class="row">
<div class="col-4 mb-3">
<%= poll.text_field :option_1, placeholder: "Option", class: "form-control"%>
<%= f.text_field :option_1, placeholder: "Option", class: "form-control"%>
</div>
<div class="col-4 mb-3">
<%= poll.text_field :option_2, placeholder: "Option", class: "form-control"%>
<%= f.text_field :option_2, placeholder: "Option", class: "form-control"%>
</div>
<div class="col-4 mb-3">
<%= poll.text_field :option_3, placeholder: "Option", class: "form-control hidden"%>
<%= f.text_field :option_3, placeholder: "Option", class: "form-control d-none"%>
</div>
<div class="col-4 mb-3">
<%= poll.text_field :option_4, placeholder: "Option", class: "form-control hidden"%>
<%= f.text_field :option_4, placeholder: "Option", class: "form-control d-none"%>
</div>
<div class="col-4 mb-3">
<%= poll.text_field :option_5, placeholder: "Option", class: "form-control hidden"%>
<%= f.text_field :option_5, placeholder: "Option", class: "form-control d-none"%>
</div>
</div>
<div class="row d-flex justify-content-between">
<div class="col-3">
<%= poll.submit "Add poll", method: :post, class: "btn btn-primary" %>
<% if f.object.persisted?%>
<%= f.submit "Edit poll", method: :post, class: "btn btn-primary" %>
<% else %>
<%= f.submit "Add poll", method: :post, class: "btn btn-primary" %>
<% end %>
</div>
<div class="col-5">
<%= poll.button "Add option", class: "btn btn-success", style: "width: 100%;" %>
<%= f.button "Add option", class: "btn btn-success", style: "width: 100%;" %>
</div>
</div>
<% end %>
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
post '/reset_password', to: 'reset_password#create'
get '/reset_password/edit', to: 'reset_password#edit'
patch '/reset_password/update', to: 'reset_password#update'
get '/poll/new', to: 'polls#new'
resources :polls, only: %i[new]
end
2 changes: 1 addition & 1 deletion coverage/.last_run.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"result": {
"line": 98.91
"line": 97.75
}
}
156 changes: 7 additions & 149 deletions coverage/.resultset.json
Original file line number Diff line number Diff line change
Expand Up @@ -305,16 +305,16 @@
null,
1,
1,
3,
2,
null,
null,
null,
1,
1,
4,
3,
1,
4,
4,
3,
3,
null,
null
]
Expand Down Expand Up @@ -386,69 +386,16 @@
null
]
},
"/home/igor/Рабочий стол/home_practice/RoR-practice/app/models/poll.rb": {
"lines": [
1,
1,
1,
1,
null,
1,
1,
1,
null
]
},
"/home/igor/Рабочий стол/home_practice/RoR-practice/spec/models/poll_membership_spec.rb": {
"/home/igor/Рабочий стол/home_practice/RoR-practice/app/policies/session_policy.rb": {
"lines": [
null,
null,
1,
null,
1,
1,
2,
2,
null,
null
]
},
"/home/igor/Рабочий стол/home_practice/RoR-practice/app/models/poll_membership.rb": {
"lines": [
1,
1,
1,
null
]
},
"/home/igor/Рабочий стол/home_practice/RoR-practice/spec/policies/poll_policy_spec.rb": {
"lines": [
null,
null,
1,
null,
1,
3,
null,
1,
2,
null,
2,
null,
1,
2,
null,
2,
null,
null
]
},
"/home/igor/Рабочий стол/home_practice/RoR-practice/app/policies/poll_policy.rb": {
"lines": [
null,
null,
1,
1,
2,
null,
null
Expand All @@ -463,105 +410,16 @@
1,
null,
1,
6,
null,
null,
1,
0,
null,
null
]
},
"/home/igor/Рабочий стол/home_practice/RoR-practice/spec/policies/user_policy_spec.rb": {
"lines": [
null,
null,
1,
null,
1,
5,
1,
3,
2,
2,
null,
null,
1,
3,
2,
2,
null,
null
]
},
"/home/igor/Рабочий стол/home_practice/RoR-practice/app/policies/user_policy.rb": {
"lines": [
null,
null,
1,
1,
2,
null,
null,
1,
2,
null,
null
]
},
"/home/igor/Рабочий стол/home_practice/RoR-practice/spec/controllers/polls_controller_spec.rb": {
"lines": [
null,
null,
1,
null,
1,
1,
1,
1,
null,
null
]
},
"/home/igor/Рабочий стол/home_practice/RoR-practice/app/controllers/polls_controller.rb": {
"lines": [
1,
1,
0,
0,
null,
null
]
},
"/home/igor/Рабочий стол/home_practice/RoR-practice/app/controllers/application_controller.rb": {
"lines": [
null,
null,
1,
1,
null,
1,
1,
null,
1,
0,
null,
null,
1,
0,
0,
0,
4,
null,
null,
1,
0,
0,
0,
null,
null
]
}
},
"timestamp": 1622503286
"timestamp": 1622577122
}
}
Loading

0 comments on commit 0c6d9de

Please sign in to comment.