Browse Source

Removes show_hidden and secret_name

Maarten van den Berg 7 years ago
parent
commit
baf294dc1c

+ 1 - 1
app/controllers/activities_controller.rb

117
 
117
 
118
     # Never trust parameters from the scary internet, only allow the white list through.
118
     # Never trust parameters from the scary internet, only allow the white list through.
119
     def activity_params
119
     def activity_params
120
-      params.require(:activity).permit(:public_name, :secret_name, :description, :location, :start, :end, :deadline, :show_hidden)
120
+      params.require(:activity).permit(:public_name, :description, :location, :start, :end, :deadline)
121
     end
121
     end
122
 end
122
 end

+ 1 - 15
app/models/activity.rb

3
 class Activity < ApplicationRecord
3
 class Activity < ApplicationRecord
4
   # @!attribute public_name
4
   # @!attribute public_name
5
   #   @return [String]
5
   #   @return [String]
6
-  #     the name that users will see if there is no {#secret_name}, or if
7
-  #     {#show_hidden} is `false`.
8
-  #
9
-  # @!attribute secret_name
10
-  #   @return [String]
11
-  #     a name that is (be default) only visible to organizers and group
12
-  #     leaders.  Can be shown or hidden to normal participants using
13
-  #     {#show_hidden}.
6
+  #     a short name for the activity.
14
   #
7
   #
15
   # @!attribute description
8
   # @!attribute description
16
   #   @return [String]
9
   #   @return [String]
22
   #     a short text describing where the activity will take place. Always
15
   #     a short text describing where the activity will take place. Always
23
   #     visible to all participants.
16
   #     visible to all participants.
24
   #
17
   #
25
-  # @!attribute show_hidden
26
-  #   @return [Boolean]
27
-  #     Whether or not the 'secret' attributes can be viewed by the people who
28
-  #     aren't organizers or group leaders. Currently, only {#secret_name} is
29
-  #     influenced by this. More attributes may be added in the future, and
30
-  #     will be controlled by this toggle as well.
31
-  #
32
   # @!attribute start
18
   # @!attribute start
33
   #   @return [TimeWithZone]
19
   #   @return [TimeWithZone]
34
   #     when the activity starts.
20
   #     when the activity starts.

+ 2 - 14
app/views/activities/_form.html.erb

13
 
13
 
14
   <div class="actions">
14
   <div class="actions">
15
     <div class="form-group">
15
     <div class="form-group">
16
-      <div class="row">
17
-        <div class="col-md-6">
18
-          <%= f.label :public_name %>
19
-          <%= f.text_field :public_name, class: 'form-control' %>
20
-        </div>
21
-        <div class="col-md-6">
22
-          <%= f.label :secret_name %>
23
-          <%= f.text_field :secret_name, class: 'form-control' %>
24
-        </div>
25
-      </div>
16
+      <%= f.label :public_name %>
17
+      <%= f.text_field :public_name, class: 'form-control' %>
26
     </div>
18
     </div>
27
     <div class="form-group">
19
     <div class="form-group">
28
       <div class="row">
20
       <div class="row">
44
       <%= f.label :deadline %>
36
       <%= f.label :deadline %>
45
       <%= f.datetime_field :deadline, class: 'form-control' %>
37
       <%= f.datetime_field :deadline, class: 'form-control' %>
46
     </div>
38
     </div>
47
-    <div class="form-group">
48
-      <%= f.label :show_hidden %>
49
-      <%= f.check_box :show_hidden %>
50
-    </div>
51
     <%= f.submit %>
39
     <%= f.submit %>
52
   </div>
40
   </div>
53
 <% end %>
41
 <% end %>

+ 0 - 5
app/views/dashboard/home.html.haml

27
                   %tr{class: p.row_class, data: {activity_id: e.id, person_id: current_person.id}}
27
                   %tr{class: p.row_class, data: {activity_id: e.id, person_id: current_person.id}}
28
                     %td
28
                     %td
29
                       = e.public_name
29
                       = e.public_name
30
-                      - if e.secret_name && e.participants.first.is_organizer
31
-                        %i
32
-                          = "(#{e.secret_name})"
33
                     %td
30
                     %td
34
                       = e.group.name
31
                       = e.group.name
35
                     %td
32
                     %td
67
                   %td
64
                   %td
68
                     = link_to group_activity_url(a.group, a) do
65
                     = link_to group_activity_url(a.group, a) do
69
                       = a.public_name
66
                       = a.public_name
70
-                      - if a.secret_name
71
-                        = "(#{a.secret_name})"
72
                       = render partial: "activities/state_counts", locals: {counts: a.state_counts}
67
                       = render partial: "activities/state_counts", locals: {counts: a.state_counts}
73
 
68
 
74
   .row
69
   .row

+ 13 - 0
db/migrate/20170815155155_remove_secret_name_from_activity.rb

1
+class RemoveSecretNameFromActivity < ActiveRecord::Migration[5.0]
2
+  def up
3
+    remove_column :activities, :secret_name
4
+    remove_column :activities, :show_hidden
5
+    rename_column :activities, :public_name, :name
6
+  end
7
+
8
+  def down
9
+    rename_column :activities, :name, :public_name
10
+    add_column :activities, :secret_name, :string
11
+    add_column :activities, :show_hidden, :boolean
12
+  end
13
+end

+ 2 - 4
db/schema.rb

10
 #
10
 #
11
 # It's strongly recommended that you check this file into your version control system.
11
 # It's strongly recommended that you check this file into your version control system.
12
 
12
 
13
-ActiveRecord::Schema.define(version: 20170222104408) do
13
+ActiveRecord::Schema.define(version: 20170815155155) do
14
 
14
 
15
   create_table "activities", force: :cascade do |t|
15
   create_table "activities", force: :cascade do |t|
16
-    t.string   "public_name"
17
-    t.string   "secret_name"
16
+    t.string   "name"
18
     t.string   "description"
17
     t.string   "description"
19
     t.string   "location"
18
     t.string   "location"
20
     t.datetime "start"
19
     t.datetime "start"
21
     t.datetime "end"
20
     t.datetime "end"
22
     t.datetime "deadline"
21
     t.datetime "deadline"
23
-    t.boolean  "show_hidden"
24
     t.integer  "group_id"
22
     t.integer  "group_id"
25
     t.datetime "created_at",  null: false
23
     t.datetime "created_at",  null: false
26
     t.datetime "updated_at",  null: false
24
     t.datetime "updated_at",  null: false

+ 0 - 10
db/seeds.rb

52
 
52
 
53
 a = Activity.create!(
53
 a = Activity.create!(
54
   public_name: 'Fikkie stoken ofzo',
54
   public_name: 'Fikkie stoken ofzo',
55
-  secret_name: 'Bosbrandopkomst',
56
   description: 'Een scout trekt er samen met anderen op uit',
55
   description: 'Een scout trekt er samen met anderen op uit',
57
   location: 'In het bos in het bos',
56
   location: 'In het bos in het bos',
58
   start: 4.weeks.since,
57
   start: 4.weeks.since,
59
   end: 4.weeks.since + 2.hours,
58
   end: 4.weeks.since + 2.hours,
60
   deadline: 3.weeks.since,
59
   deadline: 3.weeks.since,
61
-  show_hidden: false,
62
   group: g
60
   group: g
63
 )
61
 )
64
 
62
 
65
 Group.all.each do |g|
63
 Group.all.each do |g|
66
   10.times do |i|
64
   10.times do |i|
67
-    if Faker::Boolean.boolean(0.25)
68
-      secret_name = Faker::Hacker.ingverb
69
-    else
70
-      secret_name = nil
71
-    end
72
-
73
     starttime = Faker::Time.between(DateTime.now, 1.years.since, :morning)
65
     starttime = Faker::Time.between(DateTime.now, 1.years.since, :morning)
74
     endtime   = Faker::Time.between(1.hours.since(starttime), 1.days.since(starttime), :afternoon)
66
     endtime   = Faker::Time.between(1.hours.since(starttime), 1.days.since(starttime), :afternoon)
75
     deadline  = 5.days.ago(starttime)
67
     deadline  = 5.days.ago(starttime)
76
 
68
 
77
     act = Activity.create!(
69
     act = Activity.create!(
78
       public_name: Faker::Hacker.ingverb,
70
       public_name: Faker::Hacker.ingverb,
79
-      secret_name: secret_name,
80
       description: Faker::Hipster.sentence,
71
       description: Faker::Hipster.sentence,
81
       location: Faker::Address.city,
72
       location: Faker::Address.city,
82
       start: starttime,
73
       start: starttime,
83
       end: endtime,
74
       end: endtime,
84
       deadline: deadline,
75
       deadline: deadline,
85
-      show_hidden: Faker::Boolean.boolean,
86
       group: g
76
       group: g
87
     )
77
     )
88
   end
78
   end