Browse Source

Work on events

Maarten van den Berg 8 years ago
parent
commit
db17a7b6a9

+ 5 - 4
app/controllers/activities_controller.rb

@@ -28,10 +28,11 @@ class ActivitiesController < ApplicationController
28 28
   # POST /activities.json
29 29
   def create
30 30
     @activity = Activity.new(activity_params)
31
+    @activity.group = @group
31 32
 
32 33
     respond_to do |format|
33 34
       if @activity.save
34
-        format.html { redirect_to @activity, notice: 'Activity was successfully created.' }
35
+        format.html { redirect_to group_activity_url(@group, @activity), notice: 'Activity was successfully created.' }
35 36
         format.json { render :show, status: :created, location: @activity }
36 37
       else
37 38
         format.html { render :new }
@@ -45,7 +46,7 @@ class ActivitiesController < ApplicationController
45 46
   def update
46 47
     respond_to do |format|
47 48
       if @activity.update(activity_params)
48
-        format.html { redirect_to @activity, notice: 'Activity was successfully updated.' }
49
+        format.html { redirect_to group_activity_url(@group, @activity), notice: 'Activity was successfully updated.' }
49 50
         format.json { render :show, status: :ok, location: @activity }
50 51
       else
51 52
         format.html { render :edit }
@@ -59,7 +60,7 @@ class ActivitiesController < ApplicationController
59 60
   def destroy
60 61
     @activity.destroy
61 62
     respond_to do |format|
62
-      format.html { redirect_to activities_url, notice: 'Activity was successfully destroyed.' }
63
+      format.html { redirect_to group_activities_url(@group), notice: 'Activity was successfully destroyed.' }
63 64
       format.json { head :no_content }
64 65
     end
65 66
   end
@@ -76,6 +77,6 @@ class ActivitiesController < ApplicationController
76 77
 
77 78
     # Never trust parameters from the scary internet, only allow the white list through.
78 79
     def activity_params
79
-      params.fetch(:activity, {})
80
+      params.require(:activity).permit(:public_name, :secret_name, :description, :location, :start, :end, :deadline, :show_hidden)
80 81
     end
81 82
 end

+ 1 - 1
app/controllers/groups_controller.rb

@@ -77,6 +77,6 @@ class GroupsController < ApplicationController
77 77
 
78 78
     # Never trust parameters from the scary internet, only allow the white list through.
79 79
     def group_params
80
-      params.fetch(:group, {})
80
+      params.require(:group).permit(:name)
81 81
     end
82 82
 end

+ 36 - 0
app/views/activities/_form.html.erb

@@ -12,6 +12,42 @@
12 12
   <% end %>
13 13
 
14 14
   <div class="actions">
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>
26
+    </div>
27
+    <div class="form-group">
28
+      <div class="row">
29
+        <div class="col-md-6">
30
+          <%= f.label :start %>
31
+          <%= f.datetime_field :start, class: 'form-control' %>
32
+        </div>
33
+        <div class="col-md-6">
34
+          <%= f.label :end %>
35
+          <%= f.datetime_field :end, class: 'form-control' %>
36
+        </div>
37
+      </div>
38
+    </div>
39
+    <div class="form-group">
40
+      <%= f.label :description %>
41
+      <%= f.text_area :description, class: 'form-control' %>
42
+    </div>
43
+    <div class="form-group">
44
+      <%= f.label :deadline %>
45
+      <%= f.datetime_field :deadline, class: 'form-control' %>
46
+    </div>
47
+    <div class="form-group">
48
+      <%= f.label :show_hidden %>
49
+      <%= f.check_box :show_hidden %>
50
+    </div>
15 51
     <%= f.submit %>
16 52
   </div>
17 53
 <% end %>

+ 1 - 1
app/views/activities/edit.html.erb

@@ -2,5 +2,5 @@
2 2
 
3 3
 <%= render 'form', activity: @activity %>
4 4
 
5
-<%= link_to 'Show', group_activity(@group, @activity) %> |
5
+<%= link_to 'Show', group_activity_path(@group, @activity) %> |
6 6
 <%= link_to 'Back', group_activities_path(@group) %>

+ 18 - 1
app/views/activities/show.html.erb

@@ -1,4 +1,21 @@
1
-<p id="notice"><%= notice %></p>
1
+<h2><%= @activity.public_name %></h2>
2
+
3
+<ul>
4
+  <li>Secretly <%= @activity.secret_name %></li>
5
+  <li><%= @activity.description %></li>
6
+  <li><%= @activity.location %></li>
7
+  <li><%= @activity.start %> - <%= @activity.end %></li>
8
+  <li>Deadline <%= @activity.deadline %></li>
9
+</ul>
10
+
11
+<h2>Participants (<%= @activity.participants.count %>)</h2>
12
+<ul>
13
+  <% @activity.participants.each do |p| %>
14
+    <li>
15
+      <%= p.person.full_name %>, <%= p.is_organizer %>, <%= p.attending %>
16
+    </li>
17
+  <% end %>
18
+</ul>
2 19
 
3 20
 <%= link_to 'Edit', edit_group_activity_path(@group, @activity) %> |
4 21
 <%= link_to 'Back', group_activities_path(@group) %>

+ 4 - 0
app/views/groups/_form.html.erb

@@ -12,6 +12,10 @@
12 12
   <% end %>
13 13
 
14 14
   <div class="actions">
15
+    <div class="form-group">
16
+      <%= f.label :name %>
17
+      <%= f.text_field :name, class: 'form-control' %>
18
+    </div>
15 19
     <%= f.submit %>
16 20
   </div>
17 21
 <% end %>

+ 3 - 0
app/views/groups/show.html.erb

@@ -21,6 +21,9 @@
21 21
     </li>
22 22
   <% end %>
23 23
 </ul>
24
+<%= link_to "Manage activities", group_activities_path(@group) %>
24 25
 
26
+<div>
25 27
 <%= link_to 'Edit', edit_group_path(@group) %> |
26 28
 <%= link_to 'Back', groups_path %>
29
+</div>