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

Conflicts:
	app/controllers/statistics_controller.rb
This commit is contained in:
huang 2018-02-09 15:19:17 +08:00
commit 205147cc5c
5 changed files with 43 additions and 36 deletions

View File

@ -1,8 +1,12 @@
# encoding=utf-8
class StatisticsController < ApplicationController
# GET /statistics
# 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 +39,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 +60,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
@ -70,7 +72,7 @@ class StatisticsController < ApplicationController
@statistic.save_attachments_containers(params[:attachments], User.current, true)
respond_to do |format|
if @statistic.save
format.html { redirect_to @statistic, notice: 'Statistic was successfully created.' }
format.html { redirect_to @statistic, notice: '创建成功' }
format.json { render json: @statistic, status: :created, location: @statistic }
else
format.html { render action: "new" }
@ -82,7 +84,7 @@ 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)
@ -94,7 +96,7 @@ class StatisticsController < ApplicationController
end
# @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
format.html { redirect_to @statistic, notice: 'Statistic was successfully updated.' }
format.html { redirect_to @statistic, notice: '更新成功' }
format.json { head :no_content }
else
format.html { render action: "edit" }
@ -106,7 +108,6 @@ class StatisticsController < ApplicationController
# DELETE /statistics/1
# DELETE /statistics/1.json
def destroy
@statistic = Statistic.find(params[:id])
@statistic.destroy
respond_to do |format|
@ -133,4 +134,13 @@ class StatisticsController < ApplicationController
@sub_categories = params[:main_category_id].present? ? SubCategory.where(:main_category_id => params[:main_category_id]) : SubCategory.all
end
def find_statistic
@statistic = Statistic.find(params[:id])
rescue ActiveRecord::RecordNotFound
render_404
end
def require_manager
render_403 unless (User.current.id == @statistic.user_id || User.current.admin?)
end
end

View File

@ -15,12 +15,12 @@
<% end %>
<div class="field line_field">
<label><span>*</span>数据名称:</label>
<label class="field_lab"><span>*</span>数据名称:</label>
<%= f.text_field :name, :class => "wb85" %>
<p class="cl" style="padding-left: 10%;color: red;height: 20px"><span id="input_name_notice" class="none">请输入数据名称</span></p>
</div>
<div class="field line_field mb50">
<label><span>*</span>数据分类:</label>
<label class="field_lab"><span>*</span>数据分类:</label>
<%= f.select :main_category_id, (@main_categories.collect { |mc| [mc.name, mc.id] }),
{:no_label => true}, :onchange => 'getSubCategory(this.options[this.options.selectedIndex].value)',
:class => "w150" %>
@ -31,13 +31,13 @@
</div>
</div>
<div class="field line_field">
<label>数据描述:</label>
<label class="field_lab">数据描述:</label>
<div id="statistics_description" class="new_li fl">
<%= f.text_area :description, :class => "wb85 h200 mb20", :style => "display: none;" %>
</div>
</div>
<div class="field cl">
<label>&nbsp;</label>
<label class="field_lab">&nbsp;</label>
<div class="fl">
<%= render :partial => 'attachments/form_statistic', :locals => {:container => @statistic, :isReply => @isReply} %>
</div>

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>
@ -19,9 +21,10 @@
</div>
<div class="data_info mt7 c_grey">
<span><%= statistic.creator.show_name %></span>
<span><%= format_time statistic.created_at %></span>
<span><%= statistic.main_category.name %></span>
<span><%= statistic.sub_category.try(:name) %></span>
<span><%= format_time statistic.created_at %></span>
<span><%= statistic.size %>&nbsp;KB</span>
</div>
</div>
</div>

View File

@ -1,14 +1,17 @@
<%= 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="detail_part">
<div class="data_showdetail mb20">
<div class="detail_part mt15">
<label>数据类别名称:</label>
<%= @statistic.name %>
<% if User.current.id == @statistic.user_id || User.current.admin? %>
<%= link_to '编辑', edit_statistic_path(@statistic) ,:class => "submit_btn fr mr45" %>
<% end %>
</div>
<div class="cl detail_part">
<label>描述:</label>
<label class="mt20">描述:</label>
<div id="statistic_description" style="width: 80%;">
<textarea class="detail_des fl" style="display: none;width: 85%"><%= @statistic.description %></textarea>
</div>
@ -17,14 +20,6 @@
<label>添加时间:</label>
<%= format_time @statistic.created_at %>
</div>
<div class="detail_part">
<label>用户id</label>
<%= @statistic.user_id %>
</div>
<div class="detail_part">
<label>状态:</label>
<%= @statistic.status %>
</div>
<%# 附件局部刷新 %>
<% if @attachments.present? %>
<div class="detail_part cl">
@ -36,7 +31,6 @@
<% end %>
<div class="detail_part">
<label>&nbsp;</label>
<%= link_to '编辑', edit_statistic_path(@statistic) ,:class => "submit_btn" %>
<%= link_to '返回', statistics_path ,:class=>"grey_btn" %>
</div>
</div>

View File

@ -952,9 +952,9 @@ a.syllabusbox_a_blue{ color:#3b94d6;}
.mainCon{position: relative;min-height: 100%;height: auto !important;height: 100%;}
.pos_footer{position: absolute;bottom: 0;width: 100%;clear: both;z-index: 99999; }
#create_new_statis form div.field{clear: both;zoom: 1;}
#create_new_statis form label{float: left;width: 10%;text-align: center;font-size: 14px;height: 35px;line-height: 35px;}
#create_new_statis form label span{color: red}
#create_new_statis .line_field input,#create_new_statis .line_field select{float: left;height: 35px;line-height: 35px;border-radius: 4px;}
#create_new_statis form label.field_lab{float: left;width: 10%;text-align: center;font-size: 14px;height: 35px;line-height: 35px;}
#create_new_statis form label.field_lab span{color: red}
#create_new_statis .line_field input[type='text'],#create_new_statis .line_field select{float: left;height: 35px;line-height: 35px;border-radius: 4px;}
.input_tag{height: 30px!important;border-radius: 3px!important;width: 160px}
.tag_modal span{display: inline-block;border-radius: 3px;border:1px solid #dddddd;background: #FFFFFF;padding: 3px 7px;margin-right: 5px ;margin-top: 3px}
.tag_del{cursor: pointer}
@ -985,7 +985,7 @@ a.syllabusbox_a_blue{ color:#3b94d6;}
.list_tag{border: 1px solid #F8DF8C;background: #FFFCE6;color: #3BA6DD;margin-right:10px;padding: 2px 4px;border-radius: 3px}
.attachment_file{color: #FF8D00!important;}
.data_info span{font-size: 14px;width: 17%;text-align: left;display: inline-block}
.data_info span:nth-child(2){width:26% }
.data_info span:nth-child(2){width:15% }
span.down{display: block;position: absolute;top: 13px;right: 4px;width: 12px;height: 10px;background: url(/images/user/icons_user_leftnav.png) -3px -347px no-repeat;}
.submit_btn{padding-bottom: 5px;