spina-reviews 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6539daebe7a54f568effc91ece9b4887e5883500
4
- data.tar.gz: 32f6796880a2a88efa3c57ff77877469e54f9035
3
+ metadata.gz: 15e7ee2f3cd3d7f6d1bbf5416dd627e2b54484d4
4
+ data.tar.gz: acbe2d25563a87f70d93b620a7d8dfb6c62d01ac
5
5
  SHA512:
6
- metadata.gz: 24a73d40e249e7ca3fdb5b43cb47367155d4d75281630c1b454939aed07bfe061e9d46f3b67ac36c48835f6feb53356d356c74b86f9a65537d47827db70125b5
7
- data.tar.gz: d4a4bc81d7224dd68671fbebaf31bf58631ecfb2ca682173b2724ad7d6be769d2488e8b05ccaa40e8f542d950b2226ba3e2ad88f4e8e33c7789bcef27801e45e
6
+ metadata.gz: 985cd25cf5b7e0c95f1bc73f5b30694d7d88a1c52e1ff229de216031a685043652e1a7d512429587e8524b964d2eb5a64580577145cf144e99a8cc5340ade981
7
+ data.tar.gz: b5e0b1c654e00a1c44469503c54efd23d9ffdb6d250bbb2cd645f38c4d2d791fd04f9a8e3b171a5155efeaff3c328f4cc02cf99a017d162fec789bd576f23236
@@ -10,7 +10,7 @@ module Spina
10
10
  end
11
11
 
12
12
  def index
13
- @reviews = Review.all
13
+ @reviews = Review.ordered
14
14
  @average_rating = Review.average('rating') || 0
15
15
  end
16
16
 
@@ -54,6 +54,13 @@ module Spina
54
54
  redirect_to spina.admin_reviews_url, notice: "De beoordeling is verwijderd."
55
55
  end
56
56
 
57
+ def confirm
58
+ @review = Review.find(params[:id])
59
+ @review.confirmed_at = Date.today
60
+ @review.save
61
+ redirect_to spina.admin_reviews_url
62
+ end
63
+
57
64
  private
58
65
 
59
66
  def set_breadcrumb
@@ -61,7 +68,7 @@ module Spina
61
68
  end
62
69
 
63
70
  def review_params
64
- params.require(:review).permit(:name, :rating, :created_at, :explanation)
71
+ params.require(:review).permit(:name, :rating, :created_at, :explanation, :confirmed_at)
65
72
  end
66
73
  end
67
74
  end
@@ -4,7 +4,7 @@ module Spina
4
4
  private
5
5
 
6
6
  def reviews
7
- Review.order('created_at DESC')
7
+ Review.ordered.confirmed
8
8
  end
9
9
  helper_method :reviews
10
10
 
@@ -1,5 +1,9 @@
1
1
  module Spina
2
2
  class Review < ActiveRecord::Base
3
3
  validates :name, :rating, presence: true
4
+
5
+ scope :confirmed, -> { where.not(confirmed_at: nil) }
6
+ scope :ordered, -> { order('created_at DESC') }
7
+ scope :concept, -> { where(confirmed_at: nil) }
4
8
  end
5
9
  end
@@ -17,7 +17,7 @@
17
17
  .select-dropdown= f.select :rating, [["1 ster", 1], ["2 sterren", 2], ["3 sterren", 3], ["4 sterren", 4], ["5 sterren", 5]]
18
18
  %tr
19
19
  %td
20
- Datum
20
+ Datum beoordeling
21
21
  %td
22
22
  = f.text_field :created_at, value: (@review.created_at.strftime("%d-%m-%Y") unless @review.new_record?), placeholder: "Datum van beoordeling", class: 'datepicker'
23
23
  %tr
@@ -8,6 +8,7 @@
8
8
  %table.table
9
9
  %thead
10
10
  %tr
11
+ %th
11
12
  %th Naam
12
13
  %th Beoordeling
13
14
  %th
@@ -16,18 +17,30 @@
16
17
  - if @reviews.any?
17
18
  - @reviews.each do |review|
18
19
  %tr
20
+ %td
21
+ - if review.confirmed_at.present?
22
+ %label.label.label-success
23
+ Live
24
+ - else
25
+ %label.label
26
+ Concept
19
27
  %td.nowrap
20
28
  = review.name
21
29
  %small= time_ago_in_words(review.created_at) + " geleden"
22
30
  %td
23
31
  .rating
24
32
  - review.rating.times do
25
- %i{data: {icon: '5'}}
33
+ %i.icon.icon-check{style: 'color: #ffb500'}
26
34
  - (5 - review.rating).times do
27
- %i.icon-dimmed{data: {icon: '5'}}
35
+ %i.icon-dimmed.icon.icon-check{style: 'color: #ccc'}
28
36
  %p= review.explanation
29
- %td.nowrap
30
- = link_to 'Bewerken', spina.edit_admin_review_path(review), class: 'button button-link', data: {icon: 'q'}
37
+ %td.nowrap.align-right
38
+ - if review.confirmed_at.nil?
39
+ = link_to spina.confirm_admin_review_path(review), class: 'button button-mini button-primary', data: {method: :post, confirm: "Weet je zeker dat je deze beoordeling wilt publiceren op de website?"} do
40
+ = icon('check')
41
+ Publiceer
42
+ = link_to spina.edit_admin_review_path(review), class: 'button button-link' do
43
+ = icon('pencil-outline')
31
44
 
32
45
  - else
33
46
  %tr
data/config/routes.rb CHANGED
@@ -1,5 +1,9 @@
1
1
  Spina::Engine.routes.draw do
2
2
  namespace :admin do
3
- resources :reviews
3
+ resources :reviews do
4
+ member do
5
+ post 'confirm'
6
+ end
7
+ end
4
8
  end
5
9
  end
@@ -1,5 +1,5 @@
1
1
  module Spina
2
2
  module Reviews
3
- VERSION = "0.0.3"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spina-reviews
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bram Jetten
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-25 00:00:00.000000000 Z
11
+ date: 2015-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  version: '0'
117
117
  requirements: []
118
118
  rubyforge_project:
119
- rubygems_version: 2.4.5
119
+ rubygems_version: 2.4.5.1
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: Review system for Spina