diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index b0a7be31..e41e2a43 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -359,6 +359,7 @@ class AttachmentsController < ApplicationController saved = @attachment.save respond_to do |format| format.js + format.json { render json: { attachment_id: @attachment.id, url: download_attachment_path(@attachment.id) } } format.api { if saved render :action => 'upload', :status => :created diff --git a/app/controllers/libraries_controller.rb b/app/controllers/libraries_controller.rb index db5d20b0..b7bbf836 100644 --- a/app/controllers/libraries_controller.rb +++ b/app/controllers/libraries_controller.rb @@ -8,7 +8,7 @@ class LibrariesController < ApplicationController libraries = Library.where(nil) libraries = - if current_user.logged? && params[:type] == 'mine' + if User.current.logged? && params[:type] == 'mine' libraries.where(user_id: current_user.id).order('created_at desc') else libraries.where(status: :published).order('visited_count desc') @@ -49,7 +49,7 @@ class LibrariesController < ApplicationController rescue ActiveRecord::RecordInvalid => e flash[:message] = e.record.errors.full_messages.join(',') render 'new' - rescue Libraries::SubmitService::Error => ex + rescue Libraries::SubmitService::Error, Libraries::SaveService::Error => ex flash[:message] = ex.message render 'new' end @@ -73,7 +73,7 @@ class LibrariesController < ApplicationController rescue ActiveRecord::RecordInvalid => e flash[:message] = e.record.errors.full_messages.join(',') render 'edit' - rescue Libraries::SubmitService::Error => ex + rescue Libraries::SubmitService::Error, Libraries::SaveService::Error => ex flash[:message] = ex.message render 'edit' end @@ -117,6 +117,7 @@ class LibrariesController < ApplicationController hash = params[:library].presence || {} hash[:tag_ids] = params[:tag_ids].to_s.split(',') hash[:attachment_ids] = (params[:attachments].presence || []).values.map{|h| h[:attachment_id]} + hash[:cover_id] = save_cover.try(:id) || hash[:cover_id] hash end end @@ -132,4 +133,14 @@ class LibrariesController < ApplicationController def increment_visit_count @library.increment_visited_count! if @library && @library.id end + + def save_cover + return if params[:cover_file].blank? + + attachment = Attachment.new(file: params[:cover_file]) + attachment.author = User.current + attachment.filename = Redmine::Utils.random_hex(16) + attachment.save + attachment + end end \ No newline at end of file diff --git a/app/models/library.rb b/app/models/library.rb index c0fe35ee..6029f984 100644 --- a/app/models/library.rb +++ b/app/models/library.rb @@ -17,7 +17,7 @@ class Library < ActiveRecord::Base validates :content, presence: true validates :uuid, presence: true, uniqueness: true validates :author_name, presence: true, length: { maximum: 10 } - validates :author_school_name, length: { maximum: 50 }, allow_blank: true + validates :author_school_name, presence: true, length: { maximum: 50 } acts_as_attachable diff --git a/app/views/competitions/_header.html.erb b/app/views/competitions/_header.html.erb index 18e284ec..698238cb 100644 --- a/app/views/competitions/_header.html.erb +++ b/app/views/competitions/_header.html.erb @@ -64,11 +64,30 @@ - <% if User.current.logged? %> +
+ <% if User.current.logged? %> <%= link_to (image_tag(url_to_avatar(User.current), :width =>"34", :height => "34", :class => "radius", :nhname => "avatar_image", :alt=>"头像", :id => "nh_user_logo")), user_path(User.current),:class => "fr mt15 ml40" %> - <% else %> + + <% else %> 登录/注册 - <% end %> + <% end %> +
\ No newline at end of file diff --git a/app/views/libraries/index.html.erb b/app/views/libraries/index.html.erb index 08495304..087ae03c 100644 --- a/app/views/libraries/index.html.erb +++ b/app/views/libraries/index.html.erb @@ -6,16 +6,14 @@ <%= link_to '发布案例', new_library_path, class: 'white-btn edu-filter-btn-blue fr mr10 mt8', style: 'color: #4CACFF' %>

- <% if User.current.logged? %> + <% if User.current.try(:logged?) %> <% end %>
diff --git a/app/views/users/_returnTop_btn.html.erb b/app/views/users/_returnTop_btn.html.erb index 621c9467..9bdc31d6 100644 --- a/app/views/users/_returnTop_btn.html.erb +++ b/app/views/users/_returnTop_btn.html.erb @@ -31,5 +31,8 @@
- + + + +
\ No newline at end of file diff --git a/public/images/educoder/roundedRectangle.png b/public/images/educoder/roundedRectangle.png new file mode 100755 index 00000000..0d2d0b0d Binary files /dev/null and b/public/images/educoder/roundedRectangle.png differ diff --git a/public/react/src/modules/tpm/NewHeader.js b/public/react/src/modules/tpm/NewHeader.js index 4aa4aaa0..42dcaf78 100644 --- a/public/react/src/modules/tpm/NewHeader.js +++ b/public/react/src/modules/tpm/NewHeader.js @@ -301,7 +301,10 @@ class NewHeader extends Component { {/*
  • 教学案例
  • */} -
  • 在线竞赛
  • +
  • + 在线竞赛 + +
  • {project_packages_url===null||project_packages_url===undefined||project_packages_url===""?'':'众包'} diff --git a/public/react/src/modules/tpm/SiderBar.js b/public/react/src/modules/tpm/SiderBar.js index 71e33695..a2172e48 100644 --- a/public/react/src/modules/tpm/SiderBar.js +++ b/public/react/src/modules/tpm/SiderBar.js @@ -52,7 +52,9 @@ class SiderBar extends Component {
  • - + + +
    diff --git a/public/stylesheets/educoder/edu-main.css b/public/stylesheets/educoder/edu-main.css index 05cea010..81ce5b90 100644 --- a/public/stylesheets/educoder/edu-main.css +++ b/public/stylesheets/educoder/edu-main.css @@ -1211,12 +1211,33 @@ html>body #ajax-indicator { position: fixed; } } .surfacePlot{ - width:120px; - height:90px; + cursor: pointer; + width:122px; + height:92px; background:rgba(250,250,250,1); border:1px solid rgba(221,221,221,1); } .marginuploading{ - margin: 27px 42px; + padding: 28px 43px; + position: absolute; + z-index: 10; +} +.surfacePlot:hover .marginuploading.hidden{ + background: rgba(0,0,0, 0.1); +} + +.roundedRectangles { + position: absolute; + top: 10px; + right: -22px; +} + + +.edu-menu-lists currentName{ + text-align: left; +} + +.edu-menu-lists li{ + text-align: left; } \ No newline at end of file