Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop

Conflicts:
	app/views/statistics/show.html.erb
This commit is contained in:
caishi 2018-02-09 15:17:03 +08:00
commit 953d8de96f
4 changed files with 891 additions and 116 deletions

View File

@ -3,6 +3,9 @@ class StatisticsController < ApplicationController
# GET /statistics.json
layout 'base_statistic'
before_filter :get_date, :only => [:index, :new]
before_filter :require_login
before_filter :find_statistic, :only => [:show, :edit, :update, :destroy]
before_filter :require_manager, :only =>[:edit, :update, :destroy]
def index
type = (params[:type] == "reorder_popu" ? "size" : "created_at")
@ -35,7 +38,6 @@ class StatisticsController < ApplicationController
# GET /statistics/1
# GET /statistics/1.json
def show
@statistic = Statistic.find(params[:id])
@attachments = @statistic.attachments
respond_to do |format|
format.html # show.html.erb
@ -57,7 +59,6 @@ class StatisticsController < ApplicationController
# GET /statistics/1/edit
def edit
@main_categories = MainCategory.all
@statistic = Statistic.find(params[:id])
main_category = MainCategory.find(@statistic.main_category_id)
@sub_categories = main_category.sub_categories
end
@ -82,8 +83,6 @@ class StatisticsController < ApplicationController
# PUT /statistics/1
# PUT /statistics/1.json
def update
@statistic = Statistic.find(params[:id])
respond_to do |format|
if @statistic.update_attributes(params[:statistic])
@statistic.save_attachments_containers(params[:attachments], User.current, true)
@ -99,7 +98,6 @@ class StatisticsController < ApplicationController
# DELETE /statistics/1
# DELETE /statistics/1.json
def destroy
@statistic = Statistic.find(params[:id])
@statistic.destroy
respond_to do |format|
@ -125,4 +123,16 @@ class StatisticsController < ApplicationController
@main_categories = MainCategory.all
@sub_categories = params[:main_category_id].present? ? SubCategory.where(:main_category_id => params[:main_category_id]) : SubCategory.all
end
def find_statistic
if params[:id].present?
@statistic = Statistic.find(params[:id])
else
render_403
end
end
def require_manager
render_403 unless (User.current.id == @statistic.user_id || User.current.admin?)
end
end

View File

@ -1,16 +1,18 @@
<% @statistics.each do |statistic| %>
<div class="data_list_item cl pr">
<img src="<%= url_to_avatar(statistic.creator) %>" width="50" class="fl">
<div class="homepagePostSetting" style="top: 10px;right: 12px">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li><%= link_to '编辑', edit_statistic_path(statistic) %></li>
<li><%= link_to '删除', statistic, method: :delete, data: { confirm: 'Are you sure?' } %></li>
<% if User.current.id == statistic.user_id || User.current.admin? %>
<div class="homepagePostSetting" style="top: 10px;right: 12px">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li><%= link_to '编辑', edit_statistic_path(statistic) %></li>
<li><%= link_to '删除', statistic, method: :delete, data: { confirm: 'Are you sure?' } %></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<% end %>
<div class="fl data_itemMain">
<span class="f16 mr10"> <%= link_to "#{statistic.name}", statistic %> </span>
<p class="f13 mt5 mb5 data_detail"><%= statistic.description.try(:html_safe) %></p>
@ -20,7 +22,12 @@
<div class="data_info mt7 c_grey">
<span><%= statistic.creator.show_name %></span>
<span><%= statistic.main_category.name %></span>
<span><%= statistic.sub_category.try(:name) %></span>
<% if statistic.sub_category.present? %>
<span><%= statistic.sub_category.try(:name) %></span>
<% end %>
<% if statistic.size.present? %>
<span><%= statistic.size %>&nbsp;Bytes</span>
<% end %>
<span><%= format_time statistic.created_at %></span>
</div>
</div>

View File

@ -1,12 +1,14 @@
<%= stylesheet_link_tag '/editormd/css/editormd','/editormd/css/editormd.min.css' %>
<%= javascript_include_tag '/editormd/lib/marked.min.js','/editormd/lib/prettify.min.js','/editormd/lib/raphael.min.js','/editormd/lib/underscore.min.js','/editormd/lib/sequence-diagram.min.js',
'/editormd/lib/flowchart.min.js','/editormd/lib/jquery.flowchart.min.js','/editormd/editormd.js' %>
<div class="data_showdetail">
<div class="data_showdetail mb20">
<div class="detail_part mt15">
<label>数据类别名称:</label>
<%= @statistic.name %>
<%= link_to '返回', statistics_path ,:class=>"grey_btn fr mr45 ml15" ,:style=>"padding:4px 10px" %>
<%= link_to '编辑', edit_statistic_path(@statistic) ,:class => "submit_btn fr " %>
<% if User.current.id == @statistic.user_id || User.current.admin? %>
<%= link_to '返回', statistics_path ,:class=>"grey_btn fr mr45 ml15", :style=>"padding:4px 10px" %>
<%= link_to '编辑', edit_statistic_path(@statistic) ,:class => "submit_btn fr" %>
<% end %>
</div>
<div class="cl detail_part">
@ -30,8 +32,6 @@
<% end %>
<div class="detail_part">
<label>&nbsp;</label>
</div>
</div>
<script>

File diff suppressed because it is too large Load Diff