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
@@ -40,12 +40,13 | |||
|
40 | 40 | @countries.each do |country| |
|
41 | 41 | country.sites.each do |site| |
|
42 | 42 | @site_select << ["#{site.name}, #{country.name}", site.id] |
|
43 | 43 | end |
|
44 | 44 | end |
|
45 | 45 | |
|
46 | + @announcements = Announcement.find_for_frontpage | |
|
46 | 47 | render :action => 'login', :layout => 'empty' |
|
47 | 48 | end |
|
48 | 49 | |
|
49 | 50 | def list |
|
50 | 51 | prepare_list_information |
|
51 | 52 | end |
@@ -180,16 +181,13 | |||
|
180 | 181 | if sub!=nil |
|
181 | 182 | @prob_submissions << { :count => sub.number, :submission => sub } |
|
182 | 183 | else |
|
183 | 184 | @prob_submissions << { :count => 0, :submission => nil } |
|
184 | 185 | end |
|
185 | 186 | end |
|
186 | - | |
|
187 | - @announcements = Announcement.find(:all, | |
|
188 | - :conditions => "published = 1", | |
|
189 | - :order => "created_at DESC") | |
|
187 | + @announcements = Announcement.find_published | |
|
190 | 188 | end |
|
191 | 189 | |
|
192 | 190 | def check_viewability |
|
193 | 191 | @user = User.find(session[:user_id]) |
|
194 | 192 | if (!Configuration.show_tasks_to?(@user)) and |
|
195 | 193 | ((action_name=='submission') or (action_name=='submit')) |
@@ -1,2 +1,15 | |||
|
1 | 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") | |
|
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 | + | |
|
2 | 15 | end |
@@ -16,12 +16,17 | |||
|
16 | 16 | <p> |
|
17 | 17 | <b>Published</b><br /> |
|
18 | 18 | <%= f.check_box :published %> |
|
19 | 19 | </p> |
|
20 | 20 | |
|
21 | 21 | <p> |
|
22 | + <b>Show on front page?</b><br /> | |
|
23 | + <%= f.check_box :frontpage %> | |
|
24 | + </p> | |
|
25 | + | |
|
26 | + <p> | |
|
22 | 27 | <%= f.submit "Update" %> |
|
23 | 28 | </p> |
|
24 | 29 | <% end %> |
|
25 | 30 | |
|
26 | 31 | <%= link_to 'Show', @announcement %> | |
|
27 | 32 | <%= link_to 'Back', announcements_path %> |
@@ -16,11 +16,16 | |||
|
16 | 16 | <p> |
|
17 | 17 | <b>Published</b><br /> |
|
18 | 18 | <%= f.check_box :published %> |
|
19 | 19 | </p> |
|
20 | 20 | |
|
21 | 21 | <p> |
|
22 | + <b>Show on front page?</b><br /> | |
|
23 | + <%= f.check_box :frontpage %> | |
|
24 | + </p> | |
|
25 | + | |
|
26 | + <p> | |
|
22 | 27 | <%= f.submit "Create" %> |
|
23 | 28 | </p> |
|
24 | 29 | <% end %> |
|
25 | 30 | |
|
26 | 31 | <%= link_to 'Back', announcements_path %> |
@@ -10,9 +10,14 | |||
|
10 | 10 | |
|
11 | 11 | <p> |
|
12 | 12 | <b>Published:</b> |
|
13 | 13 | <%=h @announcement.published %> |
|
14 | 14 | </p> |
|
15 | 15 | |
|
16 | + <p> | |
|
17 | + <b>Show on front page:</b> | |
|
18 | + <%=h @announcement.frontpage %> | |
|
19 | + </p> | |
|
20 | + | |
|
16 | 21 | |
|
17 | 22 | <%= link_to 'Edit', edit_announcement_path(@announcement) %> | |
|
18 | 23 | <%= link_to 'Back', announcements_path %> |
@@ -1,8 +1,14 | |||
|
1 | 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 | 9 | %b= Configuration['ui.front.welcome_message'] |
|
4 | 10 | %br/ |
|
5 | 11 | Please login to see the problem list. |
|
6 | 12 | %br/ |
|
7 | 13 | %br/ |
|
8 | 14 |
@@ -6,20 +6,21 | |||
|
6 | 6 | # to create the application database on another system, you should be using db:schema:load, not running |
|
7 | 7 | # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations |
|
8 | 8 | # you'll amass, the slower it'll run and the greater likelihood for issues). |
|
9 | 9 | # |
|
10 | 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 | 14 | create_table "announcements", :force => true do |t| |
|
15 | 15 | t.string "author" |
|
16 | 16 | t.text "body" |
|
17 | 17 | t.boolean "published" |
|
18 | 18 | t.datetime "created_at" |
|
19 | 19 | t.datetime "updated_at" |
|
20 | + t.boolean "frontpage", :default => false | |
|
20 | 21 | end |
|
21 | 22 | |
|
22 | 23 | create_table "configurations", :force => true do |t| |
|
23 | 24 | t.string "key" |
|
24 | 25 | t.string "value_type" |
|
25 | 26 | t.string "value" |
You need to be logged in to leave comments.
Login now