From 037e717937dd511795dd58ce93101d26ebb7762b Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 22 Dec 2016 15:17:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E9=82=80=E8=AF=B7=E7=A0=81?= =?UTF-8?q?=20=E7=AB=9E=E8=B5=9Bsettings=EF=BC=88=E9=83=A8=E5=88=86?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/contests_controller.rb | 6 +- app/models/contest.rb | 18 ++ app/views/contests/settings.html.erb | 214 +++++++++++++++++ app/views/layouts/base_contests.html.erb | 277 ++++------------------- app/views/layouts/base_projects.html.erb | 2 - 5 files changed, 285 insertions(+), 232 deletions(-) create mode 100644 app/views/contests/settings.html.erb diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index 82aadf229..c68eda474 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -1,6 +1,6 @@ class ContestsController < ApplicationController - before_filter :find_contest, :only => [:show] + before_filter :find_contest, :only => [:show, :settings] before_filter :is_logged, :only => [:index, :new, :create] layout "base_contests" @@ -54,4 +54,8 @@ class ContestsController < ApplicationController redirect_to signin_path unless User.current.logged? end + def settings + + end + end diff --git a/app/models/contest.rb b/app/models/contest.rb index 4a8d35262..59f7bbbe1 100644 --- a/app/models/contest.rb +++ b/app/models/contest.rb @@ -84,4 +84,22 @@ class Contest < ActiveRecord::Base def act_as_contest_activity self.contest_acts << ContestActivity.new(:user_id => self.user_id,:contest_id => self.id) end + + # 延迟生成邀请码 + def invite_code + return generate_invite_code + end + + # 生成邀请码 + # 如果已有改邀请码,则重新生成 + CODES = %W(2 3 4 5 6 7 8 9 A B C D E F G H J K L N M O P Q R S T U V W X Y Z) + def generate_invite_code + code = read_attribute(:invite_code) + if !code || code.size < 4 + code = CODES.sample(4).join + return generate_invite_code if Project.where(invite_code: code).present? + update_attribute(:invite_code, code) + end + code + end end diff --git a/app/views/contests/settings.html.erb b/app/views/contests/settings.html.erb new file mode 100644 index 000000000..f55fa6ef6 --- /dev/null +++ b/app/views/contests/settings.html.erb @@ -0,0 +1,214 @@ +
+

竞赛配置

+
+ +
+
+
+
    +
  • + + 上传图片 + +
  • +
  • + + + +
  • +
  • + + +
  • +
  • + + + (选中后对所有用户可见,否则仅对成员可见。) +
  • +
  • + 删除 +

    (友情提示:删除该竞赛后如果您想恢复,请联系系统管理员!)

    + 保存 +
  • +
+
+
+
+ +
+
+ 添加成员 +
+
+ +
+
    +
  • shashashashashashasshashashashashashshashashashashashshashashashashashshashashashashashhasha
  • +
  • shashashashashashashasha
  • +
  • shashashashashashashasha
  • +
  • shashashashashashashasha
  • + +
+
    +
  • + +

    管理员

    +
  • +
  • + +

    评委

    +
  • +
  • + +

    参赛者

    +
  • +
+
+ 取消保存 +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
序号用户角色操作
1shashasha管理人员编辑删除
2shashasha主办人编辑删除
3shashashashashashashashashahashashashashashashasha +
    +
  • + +

    管理员

    +
  • +
  • + +

    评委

    +
  • +
  • + +

    参赛者

    +
  • +
+ +
保存删除
+
+
+ +
+
+
+
+
    +
  • + + +
  • +
+ 取消保存 +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
名称操作
竞赛讨论区添加子栏目
技术讨论区下移编辑删除
学术论区上移下移编辑删除
学术论区上移编辑删除
+
+
+
+
+ + +
+ + + \ No newline at end of file diff --git a/app/views/layouts/base_contests.html.erb b/app/views/layouts/base_contests.html.erb index c42613287..7690ca27c 100644 --- a/app/views/layouts/base_contests.html.erb +++ b/app/views/layouts/base_contests.html.erb @@ -22,239 +22,58 @@
-
-
-

- <%= link_to @contest.user.try(:show_name), user_path(@contest.user), :class => "sy_cgrey" %> >  - <%= link_to @contest.name, contest_path(@contest), :class => "sy_cgrey" %> >  - <%= link_to "配置", settings_contest_path(@contest), :class => "sy_cgrey" %> -

- <% if is_contest_manager?(User.current.id, @contest.id) %> - <%= render :partial => "contests/mamager_setting" %> - <% end %> - -
- -
-
-

<%= @contest.name %>

- <% unless @contest.is_public %> - +
+
+

+ <%= link_to @contest.user.try(:show_name), user_path(@contest.user), :class => "sy_cgrey" %> >  + <%= link_to @contest.name, contest_path(@contest), :class => "sy_cgrey" %> >  + <%= link_to "配置", settings_contest_path(@contest), :class => "sy_cgrey" %> +

+ <% if is_contest_manager?(User.current.id, @contest.id) %> + <%= render :partial => "contests/mamager_setting" %> <% end %> + +
+ +
+
+

<%= @contest.name %>

+ <% unless @contest.is_public %> + + <% end %> +
+
+

+ 管理员:<%= contest_managers(@contest).count %> + 评委:<%= contest_judges(@contest).count %> + 参赛者:<%= contest_contestants(@contest).count %> +

+
+ 加入竞赛 + 邀请码:<%= @contest.invite_code %>
-

- 管理员:<%= contest_managers(@contest).count %> - 评委:<%= contest_judges(@contest).count %> - 参赛者:<%= contest_contestants(@contest).count %> -

+
+ + + <%= render_flash_messages %> + <%= yield %> + <%= call_hook :view_layouts_base_content %> +
+
+
- 加入竞赛 - 邀请码:JVCR -
-
-
- -
-

竞赛配置

-
- -
-
-
-
    -
  • - - 上传图片 - -
  • -
  • - - - -
  • -
  • - - -
  • -
  • - - - (选中后对所有用户可见,否则仅对成员可见。) -
  • -
  • - 删除 -

    (友情提示:删除该竞赛后如果您想恢复,请联系系统管理员!)

    - 保存 -
  • -
-
-
-
- -
-
- 添加成员 -
-
- -
-
    -
  • shashashashashashasshashashashashashshashashashashashshashashashashashshashashashashashhasha
  • -
  • shashashashashashashasha
  • -
  • shashashashashashashasha
  • -
  • shashashashashashashasha
  • - -
-
    -
  • - -

    管理员

    -
  • -
  • - -

    评委

    -
  • -
  • - -

    参赛者

    -
  • -
-
- 取消保存 -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
序号用户角色操作
1shashasha管理人员编辑删除
2shashasha主办人编辑删除
3shashashashashashashashashahashashashashashashasha -
    -
  • - -

    管理员

    -
  • -
  • - -

    评委

    -
  • -
  • - -

    参赛者

    -
  • -
- -
保存删除
-
-
- -
-
-
-
-
    -
  • - - -
  • -
- 取消保存 -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - -
名称操作
竞赛讨论区添加子栏目
技术讨论区下移编辑删除
学术论区上移下移编辑删除
学术论区上移编辑删除
-
-
-
-
- - -
-
-
-
- - <%= render_flash_messages %> - <%= yield %> - <%= call_hook :view_layouts_base_content %> -
- -
diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 069b2cc55..985cdacf4 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -29,8 +29,6 @@ <%= yield %> <%= call_hook :view_layouts_base_content %>
- -