diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb
index 7baca76..8d7dfdd 100644
--- a/app/controllers/admin/groups_controller.rb
+++ b/app/controllers/admin/groups_controller.rb
@@ -33,6 +33,14 @@ class Admin::GroupsController < OrbitGroupController
redirect_to admin_group_path(@group)
end
+ def updatepost
+ @post = GroupPost.find(params[:id])
+ group = @post.group
+ @post.update_attributes(post_update_params)
+ @post.save
+ redirect_to admin_group_path(group)
+ end
+
def deletepost
gp = GroupPost.find(params[:id])
gp.destroy
@@ -52,6 +60,12 @@ class Admin::GroupsController < OrbitGroupController
}
end
+ def editpost
+ render_401 and return if @post.author != current_user.id
+ @no_breadcrumb = true
+ @grouppost = @post
+ end
+
def show
@no_breadcrumb = true
@no_filter = true
@@ -263,6 +277,42 @@ class Admin::GroupsController < OrbitGroupController
p
end
+ def post_update_params
+ p = params.require(:group_post).permit!
+ p["author"] = current_user.id
+ params[:images_to_destroy].each do |img|
+ gpi = GroupPostImage.find(img) rescue nil
+ gpi.destroy if !gpi.nil?
+ end if !params[:images_to_destroy].nil?
+
+ images = @post.group_post_images
+
+ p[:group_post_images].each do |id|
+ gpi = GroupPostImage.find(id) rescue nil
+ if !gpi.nil?
+ images << gpi
+ end
+ end if !p[:group_post_images].nil?
+
+ params[:files_to_destroy].each do |fil|
+ gpf = GroupPostFile.find(fil) rescue nil
+ gpf.destroy if !gpf.nil?
+ end if !params[:files_to_destroy].nil?
+
+ files = @post.group_post_files
+
+ p[:group_post_files].each do |id|
+ gpf = GroupPostFile.find(id) rescue nil
+ if !gpf.nil?
+ files << gpf
+ end
+ end if !p[:group_post_files].nil?
+
+ p[:group_post_images] = images
+ p[:group_post_files] = files
+ p
+ end
+
def post_image_params
params.require(:group_post_image).permit!
end
diff --git a/app/controllers/orbit_group_controller.rb b/app/controllers/orbit_group_controller.rb
index 7fb729c..9483801 100644
--- a/app/controllers/orbit_group_controller.rb
+++ b/app/controllers/orbit_group_controller.rb
@@ -10,7 +10,7 @@ class OrbitGroupController < ApplicationController
when "newpost", "createpost", "members"
uid = params[:group_id].split("-").last
@group = Group.find_by(:uid => uid)
- when "showpost"
+ when "showpost", "editpost"
uid = params[:id].split("-").last
@post = GroupPost.find_by(:uid => uid)
@group = @post.group
@@ -21,7 +21,7 @@ class OrbitGroupController < ApplicationController
@access_right_level = "none"
read_or_write = @group.permission rescue "read"
case params[:action]
- when "show", "showpost", "newpost", "edit", "members"
+ when "show", "showpost", "newpost", "edit", "members", "editpost"
is_member = @group.users.include?(current_user)
if @group.admins.include?(current_user.id.to_s)
@access_right_level = "admin"
diff --git a/app/models/group.rb b/app/models/group.rb
index c699203..ea923af 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -20,5 +20,9 @@ class Group
scope :archived, ->{ where(archive: true) }
scope :not_archived, ->{ where(archive: false) }
+ def privacy_name
+ return self.privacy == "closed" ? "private" : "public"
+ end
+
end
\ No newline at end of file
diff --git a/app/views/admin/groups/_group.html.erb b/app/views/admin/groups/_group.html.erb
index b8bf856..9abfb38 100644
--- a/app/views/admin/groups/_group.html.erb
+++ b/app/views/admin/groups/_group.html.erb
@@ -24,8 +24,10 @@
<% end %>
-
+
<%= link_to group.title, admin_group_path(group) %>
@@ -44,7 +46,7 @@
diff --git a/app/views/admin/groups/_post.html.erb b/app/views/admin/groups/_post.html.erb
index ae9c972..3aaa789 100644
--- a/app/views/admin/groups/_post.html.erb
+++ b/app/views/admin/groups/_post.html.erb
@@ -1,58 +1,67 @@
- <% if !post.group_post_images.blank? %>
-

- <% else %>
-

- <% end %>
+ <% if !post.group_post_images.blank? %>
+

+ <% else %>
+

+ <% end %>
-
- <%= post.title %>
-
-
- <% content = strip_tags post.content %>
- <%= content[0..250] %>
- <%= "..." if content.length > 350 %>
-
-
-
- <%
- user = User.find(post.author) rescue nil
- if !user.nil?
- author = (user.member_profile.name == nil ? user.user_name : user.member_profile.name rescue "")
- %>
- <%= author %>
- <% end %>
-
-
-
- <% date = DateTime.parse(post.created_at.to_s).strftime("%d %B %H:%M") %>
- <%= date %>
-
-
-
+
+ <%= post.title %>
+
+
+ <% content = strip_tags post.content %>
+ <%= content[0..250] %>
+ <%= "..." if content.length > 350 %>
+
+
+
+ <%
+ user = User.find(post.author) rescue nil
+ if !user.nil?
+ author = (user.member_profile.name == nil ? user.user_name : user.member_profile.name rescue "")
+ %>
+ <%= author %>
+ <% end %>
+
+
+
+ <% date = DateTime.parse(post.created_at.to_s).strftime("%d %B %H:%M") %>
+ <%= date %>
+
+
+
diff --git a/app/views/admin/groups/_post_form.html.erb b/app/views/admin/groups/_post_form.html.erb
index f1c7552..9885174 100644
--- a/app/views/admin/groups/_post_form.html.erb
+++ b/app/views/admin/groups/_post_form.html.erb
@@ -34,13 +34,19 @@
-
+ <% if params[:action] == "editpost" %>
+
+ <% end %>
- <% if params[:action] == "editpost" %>
-
- <% end %>