Description:
added announcement to frontpage
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@290 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r151:2e9ddcc1b233 - - 7 files changed: 38 inserted, 5 deleted
@@ -34,24 +34,25 | |||||
|
34 | @country_select_with_all = [['Any',0]] |
|
34 | @country_select_with_all = [['Any',0]] |
|
35 | @countries.each do |country| |
|
35 | @countries.each do |country| |
|
36 | @country_select_with_all << [country.name, country.id] |
|
36 | @country_select_with_all << [country.name, country.id] |
|
37 | end |
|
37 | end |
|
38 |
|
38 | ||
|
39 | @site_select = [] |
|
39 | @site_select = [] |
|
40 | @countries.each do |country| |
|
40 | @countries.each do |country| |
|
41 | country.sites.each do |site| |
|
41 | country.sites.each do |site| |
|
42 | @site_select << ["#{site.name}, #{country.name}", site.id] |
|
42 | @site_select << ["#{site.name}, #{country.name}", site.id] |
|
43 | end |
|
43 | end |
|
44 | end |
|
44 | end |
|
45 |
|
45 | ||
|
|
46 | + @announcements = Announcement.find_for_frontpage | ||
|
46 | render :action => 'login', :layout => 'empty' |
|
47 | render :action => 'login', :layout => 'empty' |
|
47 | end |
|
48 | end |
|
48 |
|
49 | ||
|
49 | def list |
|
50 | def list |
|
50 | prepare_list_information |
|
51 | prepare_list_information |
|
51 | end |
|
52 | end |
|
52 |
|
53 | ||
|
53 | def help |
|
54 | def help |
|
54 | @user = User.find(session[:user_id]) |
|
55 | @user = User.find(session[:user_id]) |
|
55 | end |
|
56 | end |
|
56 |
|
57 | ||
|
57 | def submit |
|
58 | def submit |
@@ -174,28 +175,25 | |||||
|
174 | def prepare_list_information |
|
175 | def prepare_list_information |
|
175 | @problems = Problem.find_available_problems |
|
176 | @problems = Problem.find_available_problems |
|
176 | @prob_submissions = Array.new |
|
177 | @prob_submissions = Array.new |
|
177 | @user = User.find(session[:user_id]) |
|
178 | @user = User.find(session[:user_id]) |
|
178 | @problems.each do |p| |
|
179 | @problems.each do |p| |
|
179 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
180 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
180 | if sub!=nil |
|
181 | if sub!=nil |
|
181 | @prob_submissions << { :count => sub.number, :submission => sub } |
|
182 | @prob_submissions << { :count => sub.number, :submission => sub } |
|
182 | else |
|
183 | else |
|
183 | @prob_submissions << { :count => 0, :submission => nil } |
|
184 | @prob_submissions << { :count => 0, :submission => nil } |
|
184 | end |
|
185 | end |
|
185 | end |
|
186 | end |
|
186 | - |
|
187 | + @announcements = Announcement.find_published |
|
187 | - @announcements = Announcement.find(:all, |
|
||
|
188 | - :conditions => "published = 1", |
|
||
|
189 | - :order => "created_at DESC") |
|
||
|
190 | end |
|
188 | end |
|
191 |
|
189 | ||
|
192 | def check_viewability |
|
190 | def check_viewability |
|
193 | @user = User.find(session[:user_id]) |
|
191 | @user = User.find(session[:user_id]) |
|
194 | if (!Configuration.show_tasks_to?(@user)) and |
|
192 | if (!Configuration.show_tasks_to?(@user)) and |
|
195 | ((action_name=='submission') or (action_name=='submit')) |
|
193 | ((action_name=='submission') or (action_name=='submit')) |
|
196 | redirect_to :action => 'list' and return |
|
194 | redirect_to :action => 'list' and return |
|
197 | end |
|
195 | end |
|
198 | end |
|
196 | end |
|
199 |
|
197 | ||
|
200 | def prepare_grading_result(submission) |
|
198 | def prepare_grading_result(submission) |
|
201 | grading_info = Configuration.task_grading_info[submission.problem.name] |
|
199 | grading_info = Configuration.task_grading_info[submission.problem.name] |
@@ -1,2 +1,15 | |||||
|
1 | class Announcement < ActiveRecord::Base |
|
1 | class Announcement < ActiveRecord::Base |
|
|
2 | + | ||
|
|
3 | + def self.find_published | ||
|
|
4 | + Announcement.find(:all, | ||
|
|
5 | + :conditions => "(published = 1) AND (frontpage = 0)", | ||
|
|
6 | + :order => "created_at DESC") | ||
|
2 | end |
|
7 | end |
|
|
8 | + | ||
|
|
9 | + def self.find_for_frontpage | ||
|
|
10 | + Announcement.find(:all, | ||
|
|
11 | + :conditions => "(published = 1) AND (frontpage = 1)", | ||
|
|
12 | + :order => "created_at DESC") | ||
|
|
13 | + end | ||
|
|
14 | + | ||
|
|
15 | + end |
@@ -10,18 +10,23 | |||||
|
10 |
|
10 | ||
|
11 | <p> |
|
11 | <p> |
|
12 | <b>Author</b><br /> |
|
12 | <b>Author</b><br /> |
|
13 | <%= f.text_field :author %> |
|
13 | <%= f.text_field :author %> |
|
14 | </p> |
|
14 | </p> |
|
15 |
|
15 | ||
|
16 | <p> |
|
16 | <p> |
|
17 | <b>Published</b><br /> |
|
17 | <b>Published</b><br /> |
|
18 | <%= f.check_box :published %> |
|
18 | <%= f.check_box :published %> |
|
19 | </p> |
|
19 | </p> |
|
20 |
|
20 | ||
|
21 | <p> |
|
21 | <p> |
|
|
22 | + <b>Show on front page?</b><br /> | ||
|
|
23 | + <%= f.check_box :frontpage %> | ||
|
|
24 | + </p> | ||
|
|
25 | + | ||
|
|
26 | + <p> | ||
|
22 | <%= f.submit "Update" %> |
|
27 | <%= f.submit "Update" %> |
|
23 | </p> |
|
28 | </p> |
|
24 | <% end %> |
|
29 | <% end %> |
|
25 |
|
30 | ||
|
26 | <%= link_to 'Show', @announcement %> | |
|
31 | <%= link_to 'Show', @announcement %> | |
|
27 | <%= link_to 'Back', announcements_path %> |
|
32 | <%= link_to 'Back', announcements_path %> |
@@ -10,17 +10,22 | |||||
|
10 |
|
10 | ||
|
11 | <p> |
|
11 | <p> |
|
12 | <b>Author</b><br /> |
|
12 | <b>Author</b><br /> |
|
13 | <%= f.text_field :author %> |
|
13 | <%= f.text_field :author %> |
|
14 | </p> |
|
14 | </p> |
|
15 |
|
15 | ||
|
16 | <p> |
|
16 | <p> |
|
17 | <b>Published</b><br /> |
|
17 | <b>Published</b><br /> |
|
18 | <%= f.check_box :published %> |
|
18 | <%= f.check_box :published %> |
|
19 | </p> |
|
19 | </p> |
|
20 |
|
20 | ||
|
21 | <p> |
|
21 | <p> |
|
|
22 | + <b>Show on front page?</b><br /> | ||
|
|
23 | + <%= f.check_box :frontpage %> | ||
|
|
24 | + </p> | ||
|
|
25 | + | ||
|
|
26 | + <p> | ||
|
22 | <%= f.submit "Create" %> |
|
27 | <%= f.submit "Create" %> |
|
23 | </p> |
|
28 | </p> |
|
24 | <% end %> |
|
29 | <% end %> |
|
25 |
|
30 | ||
|
26 | <%= link_to 'Back', announcements_path %> |
|
31 | <%= link_to 'Back', announcements_path %> |
@@ -4,15 +4,20 | |||||
|
4 | </p> |
|
4 | </p> |
|
5 |
|
5 | ||
|
6 | <p> |
|
6 | <p> |
|
7 | <b>Body:</b> |
|
7 | <b>Body:</b> |
|
8 | <%=h @announcement.body %> |
|
8 | <%=h @announcement.body %> |
|
9 | </p> |
|
9 | </p> |
|
10 |
|
10 | ||
|
11 | <p> |
|
11 | <p> |
|
12 | <b>Published:</b> |
|
12 | <b>Published:</b> |
|
13 | <%=h @announcement.published %> |
|
13 | <%=h @announcement.published %> |
|
14 | </p> |
|
14 | </p> |
|
15 |
|
15 | ||
|
|
16 | + <p> | ||
|
|
17 | + <b>Show on front page:</b> | ||
|
|
18 | + <%=h @announcement.frontpage %> | ||
|
|
19 | + </p> | ||
|
|
20 | + | ||
|
16 |
|
21 | ||
|
17 | <%= link_to 'Edit', edit_announcement_path(@announcement) %> | |
|
22 | <%= link_to 'Edit', edit_announcement_path(@announcement) %> | |
|
18 | <%= link_to 'Back', announcements_path %> |
|
23 | <%= link_to 'Back', announcements_path %> |
@@ -1,14 +1,20 | |||||
|
1 | %h1= Configuration['ui.front.title'] |
|
1 | %h1= Configuration['ui.front.title'] |
|
2 |
|
2 | ||
|
|
3 | + - if @announcements.length!=0 | ||
|
|
4 | + .announcementbox | ||
|
|
5 | + %span{:class => 'title'} | ||
|
|
6 | + Announcements | ||
|
|
7 | + = render :partial => 'announcement', :collection => @announcements | ||
|
|
8 | + | ||
|
3 | %b= Configuration['ui.front.welcome_message'] |
|
9 | %b= Configuration['ui.front.welcome_message'] |
|
4 | %br/ |
|
10 | %br/ |
|
5 | Please login to see the problem list. |
|
11 | Please login to see the problem list. |
|
6 | %br/ |
|
12 | %br/ |
|
7 | %br/ |
|
13 | %br/ |
|
8 |
|
14 | ||
|
9 | - if flash[:notice] |
|
15 | - if flash[:notice] |
|
10 | %hr/ |
|
16 | %hr/ |
|
11 | %b= flash[:notice] |
|
17 | %b= flash[:notice] |
|
12 | %hr/ |
|
18 | %hr/ |
|
13 |
|
19 | ||
|
14 | %div{ :style => "border: solid 1px gray; padding: 2px; background: #f0f0f0;"} |
|
20 | %div{ :style => "border: solid 1px gray; padding: 2px; background: #f0f0f0;"} |
@@ -1,31 +1,32 | |||||
|
1 | # This file is auto-generated from the current state of the database. Instead of editing this file, |
|
1 | # This file is auto-generated from the current state of the database. Instead of editing this file, |
|
2 | # please use the migrations feature of Active Record to incrementally modify your database, and |
|
2 | # please use the migrations feature of Active Record to incrementally modify your database, and |
|
3 | # then regenerate this schema definition. |
|
3 | # then regenerate this schema definition. |
|
4 | # |
|
4 | # |
|
5 | # Note that this schema.rb definition is the authoritative source for your database schema. If you need |
|
5 | # Note that this schema.rb definition is the authoritative source for your database schema. If you need |
|
6 | # to create the application database on another system, you should be using db:schema:load, not running |
|
6 | # to create the application database on another system, you should be using db:schema:load, not running |
|
7 | # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations |
|
7 | # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations |
|
8 | # you'll amass, the slower it'll run and the greater likelihood for issues). |
|
8 | # you'll amass, the slower it'll run and the greater likelihood for issues). |
|
9 | # |
|
9 | # |
|
10 | # It's strongly recommended to check this file into your version control system. |
|
10 | # It's strongly recommended to check this file into your version control system. |
|
11 |
|
11 | ||
|
12 |
- ActiveRecord::Schema.define(:version => 20081 |
|
12 | + ActiveRecord::Schema.define(:version => 20081107145815) do |
|
13 |
|
13 | ||
|
14 | create_table "announcements", :force => true do |t| |
|
14 | create_table "announcements", :force => true do |t| |
|
15 | t.string "author" |
|
15 | t.string "author" |
|
16 | t.text "body" |
|
16 | t.text "body" |
|
17 | t.boolean "published" |
|
17 | t.boolean "published" |
|
18 | t.datetime "created_at" |
|
18 | t.datetime "created_at" |
|
19 | t.datetime "updated_at" |
|
19 | t.datetime "updated_at" |
|
|
20 | + t.boolean "frontpage", :default => false | ||
|
20 | end |
|
21 | end |
|
21 |
|
22 | ||
|
22 | create_table "configurations", :force => true do |t| |
|
23 | create_table "configurations", :force => true do |t| |
|
23 | t.string "key" |
|
24 | t.string "key" |
|
24 | t.string "value_type" |
|
25 | t.string "value_type" |
|
25 | t.string "value" |
|
26 | t.string "value" |
|
26 | t.datetime "created_at" |
|
27 | t.datetime "created_at" |
|
27 | t.datetime "updated_at" |
|
28 | t.datetime "updated_at" |
|
28 | end |
|
29 | end |
|
29 |
|
30 | ||
|
30 | create_table "countries", :force => true do |t| |
|
31 | create_table "countries", :force => true do |t| |
|
31 | t.string "name" |
|
32 | t.string "name" |
You need to be logged in to leave comments.
Login now