From 0b6168c7fd1d220ab463a17276be695bd711e9bb Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 23 Jul 2014 09:24:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=AB=9E=E8=B5=9B=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E5=8F=91=E5=B8=83=E9=80=9A=E7=9F=A5=E9=80=9A=E5=91=8A?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81=20=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E5=BE=97=E5=88=86=E5=8E=BB=E9=99=A4=E5=B0=8F?= =?UTF-8?q?=E6=95=B0=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 2 ++ .../contest_notification_controller.rb | 5 +++++ app/models/contest_notification.rb | 3 +++ app/views/admin/contest_page_made.html.erb | 5 ++--- app/views/contest_notification/show.html.erb | 0 app/views/projects/_member_list.html.erb | 2 +- config/routes.rb | 2 ++ ...0722080529_create_contest_notifications.rb | 10 ++++++++++ db/migrate/20140722080924_set_notification.rb | 19 +++++++++++++++++++ db/schema.rb | 9 ++++++++- 10 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 app/controllers/contest_notification_controller.rb create mode 100644 app/models/contest_notification.rb create mode 100644 app/views/contest_notification/show.html.erb create mode 100644 db/migrate/20140722080529_create_contest_notifications.rb create mode 100644 db/migrate/20140722080924_set_notification.rb diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 05045ab12..445a1a393 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -306,9 +306,11 @@ class AdminController < ApplicationController if request.get? @contest_page = FirstPage.where("page_type = 'contest'").first @first_page = FirstPage.where("page_type = 'project'").first + @notification = ContestNotification.all.first; elsif request.post? @first_page = FirstPage.where("page_type = 'project'").first @contest_page = FirstPage.where("page_type = 'contest'").first + @notification = ContestNotification.all.first; @first_page.web_title = params[:web_title] @contest_page.web_title = params[:web_title] @contest_page.title = params[:contest_title] diff --git a/app/controllers/contest_notification_controller.rb b/app/controllers/contest_notification_controller.rb new file mode 100644 index 000000000..143941cc0 --- /dev/null +++ b/app/controllers/contest_notification_controller.rb @@ -0,0 +1,5 @@ +class ContestNotificationController + def show + + end +end \ No newline at end of file diff --git a/app/models/contest_notification.rb b/app/models/contest_notification.rb new file mode 100644 index 000000000..c1f2fde6f --- /dev/null +++ b/app/models/contest_notification.rb @@ -0,0 +1,3 @@ +class ContestNotification < ActiveRecord::Base + attr_accessible :content, :title +end diff --git a/app/views/admin/contest_page_made.html.erb b/app/views/admin/contest_page_made.html.erb index ef99abf7d..d9a9b2f65 100644 --- a/app/views/admin/contest_page_made.html.erb +++ b/app/views/admin/contest_page_made.html.erb @@ -36,9 +36,8 @@

- <% labelled_form_for %> - <%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %> - + <%= text_area 'contest_notification', 'content', :value => @notification.content,:cols => 80, :rows => 15, :class => 'wiki-edit' %> + <%= wikitoolbar_for 'contest_notification_content' %>
<%= submit_tag l(:button_save), :class => "small", :name => nil %> <% end %> diff --git a/app/views/contest_notification/show.html.erb b/app/views/contest_notification/show.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/projects/_member_list.html.erb b/app/views/projects/_member_list.html.erb index 6fe6b55f0..cdf6c459d 100644 --- a/app/views/projects/_member_list.html.erb +++ b/app/views/projects/_member_list.html.erb @@ -24,7 +24,7 @@ <%= content_tag "div", content_tag("p", rolesToLanguage(member.roles.sort.collect(&:to_s)).join(', ')), :class => "clear avatar_name" %>

- <%= l(:label_user_for_project_grade) %>: <%= UserGrade.find_by_user_id_and_project_id(member[:user_id], @project.id).grade %> + <%= l(:label_user_for_project_grade) %>: <%= format("%.2f" ,UserGrade.find_by_user_id_and_project_id(member[:user_id], @project.id).grade).to_i %>

<% end %> diff --git a/config/routes.rb b/config/routes.rb index 08183f55e..948eee4a5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -42,6 +42,8 @@ RedmineApp::Application.routes.draw do end end + resources :contest_notification + resources :open_source_projects do collection do match 'search', via: [:get, :post] diff --git a/db/migrate/20140722080529_create_contest_notifications.rb b/db/migrate/20140722080529_create_contest_notifications.rb new file mode 100644 index 000000000..0aff8d268 --- /dev/null +++ b/db/migrate/20140722080529_create_contest_notifications.rb @@ -0,0 +1,10 @@ +class CreateContestNotifications < ActiveRecord::Migration + def change + create_table :contest_notifications do |t| + t.text :title + t.text :content + + t.timestamps + end + end +end diff --git a/db/migrate/20140722080924_set_notification.rb b/db/migrate/20140722080924_set_notification.rb new file mode 100644 index 000000000..87e90318c --- /dev/null +++ b/db/migrate/20140722080924_set_notification.rb @@ -0,0 +1,19 @@ +# -*coding:utf-8 -*- +class SetNotification < ActiveRecord::Migration + def change + notifications = ContestNotification.all + if notifications.nil? || notifications.count == 0 + notification = ContestNotification.new + notification.title = "2014年Android程序设计大赛获奖名单" + notification.content = "
一等奖: 消灭那怪兽
+
二等奖: 兄弟向前冲
+
二等奖: 鸟鸟文件管理器(银河之光版)
+
三等奖: 疯狂猜图
+
三等奖: 愉快的定向越野
+
三等奖: 体能训练助手
+
三等奖: 迷你日记本
+
三等奖: 永齐飞机大战
" + notification.save + end + end +end diff --git a/db/schema.rb b/db/schema.rb index c4d359dab..870703254 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140722024513) do +ActiveRecord::Schema.define(:version => 20140722080924) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -241,6 +241,13 @@ ActiveRecord::Schema.define(:version => 20140722024513) do add_index "comments", ["author_id"], :name => "index_comments_on_author_id" add_index "comments", ["commented_id", "commented_type"], :name => "index_comments_on_commented_id_and_commented_type" + create_table "contest_notifications", :force => true do |t| + t.text "title" + t.text "content" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "contesting_projects", :force => true do |t| t.integer "project_id" t.string "contest_id"