Description:
merge
Commit status:
[Not Reviewed]
References:
merge algo
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r840:b948bb241476 - - 9 files changed: 113 inserted, 49 deleted

@@ -0,0 +1,25
1 + = simple_form_for(@announcement) do |f|
2 + - if @announcement.errors.any?
3 + .form-row
4 + .col-sm-12
5 + #error_explanation.alert.alert-dismissable.alert-danger
6 + %button.close{type: "button", data: { dismiss: "alert"}, aria: {hidden: "true"}} ×
7 + %h3= "เกิดปัญหาในการบันทึกข้อมูลเนื่องจาก"
8 + %ul
9 + - @announcement.errors.full_messages.each do |message|
10 + %li= message
11 + .form-row
12 + .col-md-6.col-12
13 + -# = f.input :lock_version, as: :hidden
14 + = f.input :title
15 + = f.input :notes, label: 'Notes (shown internally, used to organize announcements)'
16 + = f.input :body
17 + = f.input :author
18 + = f.input :published
19 + = f.input :frontpage, label: 'Display in the front page only?'
20 + = f.input :on_nav_bar, label: 'Show on menu bar?', wrapper: :custom_boolean
21 + = f.input :contest_only, label: 'Display in contest only?'
22 + = f.submit "Create", class: 'btn btn-primary'
23 + -if content_for?(:form_buttons)
24 + = yield(:form_buttons)
25 + / = link_to 'Back', announcements_path, class: 'btn btn-default'
@@ -0,0 +1,5
1 + class AddOnNavBarToAnnouncement < ActiveRecord::Migration[5.2]
2 + def change
3 + add_column :announcements, :on_nav_bar, :boolean, default: false
4 + end
5 + end
@@ -111,6 +111,6
111 private
111 private
112
112
113 def announcement_params
113 def announcement_params
114 - params.require(:announcement).permit(:author, :body, :published, :frontpage, :contest_only, :title)
114 + params.require(:announcement).permit(:author, :body, :published, :frontpage, :contest_only, :title, :on_nav_bar)
115 end
115 end
116 end
116 end
@@ -4,6 +4,7
4 protect_from_forgery
4 protect_from_forgery
5
5
6 before_action :current_user
6 before_action :current_user
7 + before_action :nav_announcement
7
8
8 SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode'
9 SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode'
9 MULTIPLE_IP_LOGIN_CONF_KEY = 'right.multiple_ip_login'
10 MULTIPLE_IP_LOGIN_CONF_KEY = 'right.multiple_ip_login'
@@ -22,6 +23,10
22 @current_user ||= User.find(session[:user_id])
23 @current_user ||= User.find(session[:user_id])
23 end
24 end
24
25
26 + def nav_announcement
27 + @nav_announcement = Announcement.where(on_nav_bar: true)
28 + end
29 +
25 def admin_authorization
30 def admin_authorization
26 return false unless check_valid_login
31 return false unless check_valid_login
27 user = User.includes(:roles).find(session[:user_id])
32 user = User.includes(:roles).find(session[:user_id])
@@ -1,34 +1,45
1 - .container-fluid
1 + %h1 Edit Announcement
2 - %h1 Editing announcement
2 +
3 - = error_messages_for :announcement
3 + -content_for(:form_buttons) do
4 - .row
4 + = link_to t(:back), announcements_path, class: 'card-link btn btn-secondary'
5 - .col-md-6
5 +
6 - = form_for(@announcement) do |f|
6 + = render 'form'
7 - .form-group
7 + -# old style
8 - %label Title
8 + .container-fluid
9 - = f.text_field :title, class: 'form-control'
9 + %h1 Editing announcement
10 - .form-group
10 + = error_messages_for :announcement
11 - %label Notes
11 + .row
12 - (shown internally, used to organize announcements)
12 + .col-md-6
13 - = f.text_field :notes, class: 'form-control'
13 + = form_for(@announcement) do |f|
14 - .form-group
14 + .form-group
15 - %label Body
15 + %label Title
16 - = f.text_area :body, class: 'form-control', style: 'height: 200px;'
16 + = f.text_field :title, class: 'form-control'
17 - .form-group
17 + .form-group
18 - %label Author
18 + %label Notes
19 - = f.text_field :author, class: 'form-control'
19 + (shown internally, used to organize announcements)
20 - .checkbox
20 + = f.text_field :notes, class: 'form-control'
21 - %label
21 + .form-group
22 - = f.check_box :published
22 + %label Body
23 - Published
23 + = f.text_area :body, class: 'form-control', style: 'height: 200px;'
24 - .checkbox
24 + .form-group
25 - %label
25 + %label Author
26 - = f.check_box :frontpage
26 + = f.text_field :author, class: 'form-control'
27 - Show on front page?
27 + .checkbox
28 - .checkbox
28 + %label
29 - %label
29 + = f.check_box :published
30 - = f.check_box :contest_only
30 + Published
31 - Show only in contest?
31 + .checkbox
32 - = f.submit "Update", class: 'btn btn-primary'
32 + %label
33 - = link_to 'Show', @announcement, class: 'btn btn-default'
33 + = f.check_box :frontpage
34 - = link_to 'Back', announcements_path, class: 'btn btn-default'
34 + Show on front page?
35 + .checkbox
36 + %label
37 + = f.check_box :on_nav_bar
38 + Show on top menu bar?
39 + .checkbox
40 + %label
41 + = f.check_box :contest_only
42 + Show only in contest?
43 + = f.submit "Update", class: 'btn btn-primary'
44 + = link_to 'Show', @announcement, class: 'btn btn-default'
45 + = link_to 'Back', announcements_path, class: 'btn btn-default'
@@ -1,14 +1,22
1 %h1 New announcement
1 %h1 New announcement
2 - = error_messages_for :announcement
2 +
3 - = simple_form_for(@announcement) do |f|
3 + -content_for(:form_buttons) do
4 - .row
4 + = link_to t(:back), announcements_path, class: 'card-link btn btn-secondary'
5 - .col-md-6
5 +
6 - = f.input :title
6 + = render 'form'
7 - = f.input :notes, label: 'Notes (shown internally, used to organize announcements)'
7 +
8 - = f.input :body
8 + -# old style
9 - = f.input :author
9 + = error_messages_for :announcement
10 - = f.input :published
10 + = simple_form_for(@announcement) do |f|
11 - = f.input :frontpage, label: 'Display in the front page only?'
11 + .row
12 - = f.input :contest_only, label: 'Display in contest only?'
12 + .col-md-6
13 - = f.button :submit, "Create", class: 'btn btn-primary'
13 + = f.input :title
14 - = link_to 'Back', announcements_path, class: 'btn btn-default'
14 + = f.input :notes, label: 'Notes (shown internally, used to organize announcements)'
15 + = f.input :body
16 + = f.input :author
17 + = f.input :published
18 + = f.input :frontpage, label: 'Display in the front page only?'
19 + = f.input :contest_only, label: 'Display in contest only?'
20 + = f.button :submit, "Create", class: 'btn btn-primary'
21 + = link_to 'Back', announcements_path, class: 'btn btn-default'
22 +
@@ -17,6 +17,9
17 %b Show on front page:
17 %b Show on front page:
18 = h @announcement.frontpage
18 = h @announcement.frontpage
19 %p
19 %p
20 + %b Show on top menu bar:
21 + = h @announcement.on_nav_bar
22 + %p
20 %b Show only in contest:
23 %b Show only in contest:
21 = h @announcement.contest_only
24 = h @announcement.contest_only
22 = link_to 'Edit', edit_announcement_path(@announcement)
25 = link_to 'Edit', edit_announcement_path(@announcement)
@@ -70,6 +70,12
70 =link_to "#{ungraded} backlogs!",
70 =link_to "#{ungraded} backlogs!",
71 graders_list_path,
71 graders_list_path,
72 class: 'navbar-btn btn btn-default btn-warning', data: {toggle: 'tooltip'},title: 'Number of ungraded submission'
72 class: 'navbar-btn btn btn-default btn-warning', data: {toggle: 'tooltip'},title: 'Number of ungraded submission'
73 + / announcement
74 + - @nav_announcement.each do |ann|
75 + %p.navbar-text
76 + = ann.body.html_safe
77 +
78 +
73
79
74 %ul.nav.navbar-nav.navbar-right
80 %ul.nav.navbar-nav.navbar-right
75 = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-question-sign')}".html_safe, 'main', 'help')
81 = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-question-sign')}".html_safe, 'main', 'help')
@@ -10,7 +10,7
10 #
10 #
11 # It's strongly recommended that you check this file into your version control system.
11 # It's strongly recommended that you check this file into your version control system.
12
12
13 - ActiveRecord::Schema.define(version: 2020_08_13_083020) do
13 + ActiveRecord::Schema.define(version: 2021_01_24_101028) do
14
14
15 create_table "announcements", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
15 create_table "announcements", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
16 t.string "author"
16 t.string "author"
@@ -22,6 +22,7
22 t.boolean "contest_only", default: false
22 t.boolean "contest_only", default: false
23 t.string "title"
23 t.string "title"
24 t.string "notes"
24 t.string "notes"
25 + t.boolean "on_nav_bar", default: false
25 end
26 end
26
27
27 create_table "contests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
28 create_table "contests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
You need to be logged in to leave comments. Login now