From 94a7bacdd29f711c699e860f8d0793e993421e83 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Mon, 21 Apr 2014 19:36:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=A6=96=E9=A1=B5=EF=BC=9A=E5=BD=93?= =?UTF-8?q?=E6=97=A0=E5=BA=94=E7=94=A8=E6=97=B6=EF=BC=8C=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E6=9A=82=E6=97=A0=E5=BA=94=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../softapplications_controller.rb | 55 ++++++++++--------- app/helpers/application_helper.rb | 9 +++ app/views/welcome/contest.html.erb | 53 ++++++++++-------- 3 files changed, 66 insertions(+), 51 deletions(-) diff --git a/app/controllers/softapplications_controller.rb b/app/controllers/softapplications_controller.rb index 9ac62f92..9f14aa11 100644 --- a/app/controllers/softapplications_controller.rb +++ b/app/controllers/softapplications_controller.rb @@ -17,18 +17,18 @@ class SoftapplicationsController < ApplicationController @jours = @softapplication.journals_for_messages.order('created_on DESC') @image_results = [] @softapplication.attachments.each do |f| - f.image? ? @image_results << f : @image_results + f.image? ? @image_results << f : @image_results end - @app_items = [] + @app_items = [] @softapplication.attachments.each do |f| - f.pack? ? @app_items << f : @app_items + f.pack? ? @app_items << f : @app_items end @limit = 10 @feedback_count = @jours.count @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] @offset ||= @feedback_pages.offset @jour = @jours[@offset, @limit] - @state = false + @state = false respond_to do |format| format.html # show.html.erb format.json { render json: @softapplication } @@ -83,11 +83,10 @@ class SoftapplicationsController < ApplicationController end end end - - + def add_attach @softapplication = Softapplication.find(params[:id]) - @softapplication.save_attachments(params[:attachments]) + @softapplication.save_attachments(params[:attachments]) end # DELETE /softapplications/1 @@ -101,15 +100,16 @@ class SoftapplicationsController < ApplicationController format.json { head :no_content } end end + #应用评价涉及到的方法 def new_message @jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id] if @jour - user = @jour.user - text = @jour.notes + user = @jour.user + text = @jour.notes else - user = @softapplication.user - text = @softapplication.description + user = @softapplication.user + text = @softapplication.description end text = text.to_s.strip.gsub(%r{
((.|\s)*?)
}m, '[...]') @content = "> #{ll(User.current.language, :text_user_wrote, user)}\n> " @@ -117,25 +117,24 @@ class SoftapplicationsController < ApplicationController @id = user.id rescue ActiveRecord::RecordNotFound render_404 - end - #新建评价 - def create_message - - if params[:softapplication_message][:message].size>0 - if params[:reference_content] - message = params[:softapplication_message][:message] + "\n" + params[:reference_content] - else - message = params[:softapplication_message][:message] - end - refer_user_id = params[:softapplication_message][:reference_user_id].to_i - @softapplication = Softapplication.find(params[:id]) - @softapplication.add_jour(User.current, message, refer_user_id) - end - + + #新建评价 + def create_message + + if params[:reference_content] + message = params[:softapplication_message][:message] + "\n" + params[:reference_content] + else + message = params[:softapplication_message][:message] + end + refer_user_id = params[:softapplication_message][:reference_user_id].to_i + @softapplication = Softapplication.find(params[:id]) + @softapplication.add_jour(User.current, message, refer_user_id) + + @user = @softapplication.user @jours = @softapplication.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') - + @limit = 10 @feedback_count = @jours.count @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] @@ -167,6 +166,7 @@ class SoftapplicationsController < ApplicationController format.js end end + # def more @jour = @softapplication.journals_for_messages @@ -179,6 +179,7 @@ class SoftapplicationsController < ApplicationController #format.api { render_api_ok } end end + # def back @jour = @softapplication.journals_for_messages diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1d639726..ad90f894 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1608,4 +1608,13 @@ module ApplicationHelper User.current end + # def hadcommittedforcontest(curu) + # message = JournalsForMessage.find_by_sql("select * from journals_for_messages where jour_type = 'Softapplication' ") + # message.each do |createmessage| + # if createmessage.user_id == curu + # return true + # end + # end + # end + end diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index 8c0addb8..b91e05cc 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -196,32 +196,37 @@

最新参赛应用

- +
-
- <% find_all_hot_softapplication.map do |softapplication| break if(softapplication == find_all_hot_softapplication[5]) %> + <% if Softapplication.count > 0%> +
+ <% find_all_hot_softapplication.map do |softapplication| break if(softapplication == find_all_hot_softapplication[5]) %> + +
  • +
    + <%= image_tag('/images/009.gif')%> +
    + +
    + <%= link_to(softapplication.name, softapplication_path(softapplication.id), :class => "d-g-blue d-p-project-name", :title => "#{softapplication.name}", :target => "_blank") %> +
    + +
    + ><%=softapplication.description.truncate(50, omission: '...')%> +

    + +
    + 发布时间:<%=format_time softapplication.created_at %> +
    + +
  • + <% end; reset_cycle %> + +
    + <% else %> +

    <%= l(:label_no_bid_project) %>

    -
  • -
    - <%= image_tag('/images/009.gif')%> -
    - -
    - <%= link_to(softapplication.name, softapplication_path(softapplication.id), :class => "d-g-blue d-p-project-name", :title => "#{softapplication.name}", :target => "_blank") %> -
    - -
    - ><%=softapplication.description.truncate(50, omission: '...')%> -

    - -
    - 发布时间:<%=format_time softapplication.created_at %> -
    - -
  • - <% end; reset_cycle %> - -
    + <% end %>
    From 8a429ec669b03a8ecafa597b31f694394b759f9a Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Mon, 21 Apr 2014 19:37:23 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/contest.html.erb | 2 +- config/locales/zh.yml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index b91e05cc..f283bd75 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -224,7 +224,7 @@ <% else %> -

    <%= l(:label_no_bid_project) %>

    +

    <%= l(:label_no_ftapplication) %>

    <% end %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 4bcb2373..079ad450 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1854,6 +1854,7 @@ zh: label_tags_contest_description: 竞赛描述 label_release_add_contest_succeed: 该应用发布并添加成功. label_add_contest_succeed_fail: 添加失败,该应用已参赛. + label_no_ftapplication: 暂无应用 - + \ No newline at end of file