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: 66 inserted, 2 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
@@ -108,9 +108,9
108 108 end
109 109 end
110 110
111 111 private
112 112
113 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 115 end
116 116 end
@@ -1,12 +1,13
1 1 require 'ipaddr'
2 2
3 3 class ApplicationController < ActionController::Base
4 4 protect_from_forgery
5 5
6 6 before_action :current_user
7 + before_action :nav_announcement
7 8
8 9 SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode'
9 10 MULTIPLE_IP_LOGIN_CONF_KEY = 'right.multiple_ip_login'
10 11 WHITELIST_IGNORE_CONF_KEY = 'right.whitelist_ignore'
11 12 WHITELIST_IP_CONF_KEY = 'right.whitelist_ip'
12 13
@@ -19,12 +20,16
19 20 # Returns the current logged-in user (if any).
20 21 def current_user
21 22 return nil unless session[:user_id]
22 23 @current_user ||= User.find(session[:user_id])
23 24 end
24 25
26 + def nav_announcement
27 + @nav_announcement = Announcement.where(on_nav_bar: true)
28 + end
29 +
25 30 def admin_authorization
26 31 return false unless check_valid_login
27 32 user = User.includes(:roles).find(session[:user_id])
28 33 unless user.admin?
29 34 unauthorized_redirect
30 35 return false
@@ -1,6 +1,13
1 + %h1 Edit Announcement
2 +
3 + -content_for(:form_buttons) do
4 + = link_to t(:back), announcements_path, class: 'card-link btn btn-secondary'
5 +
6 + = render 'form'
7 + -# old style
1 8 .container-fluid
2 9 %h1 Editing announcement
3 10 = error_messages_for :announcement
4 11 .row
5 12 .col-md-6
6 13 = form_for(@announcement) do |f|
@@ -24,11 +31,15
24 31 .checkbox
25 32 %label
26 33 = f.check_box :frontpage
27 34 Show on front page?
28 35 .checkbox
29 36 %label
37 + = f.check_box :on_nav_bar
38 + Show on top menu bar?
39 + .checkbox
40 + %label
30 41 = f.check_box :contest_only
31 42 Show only in contest?
32 43 = f.submit "Update", class: 'btn btn-primary'
33 44 = link_to 'Show', @announcement, class: 'btn btn-default'
34 45 = link_to 'Back', announcements_path, class: 'btn btn-default'
@@ -1,7 +1,14
1 1 %h1 New announcement
2 +
3 + -content_for(:form_buttons) do
4 + = link_to t(:back), announcements_path, class: 'card-link btn btn-secondary'
5 +
6 + = render 'form'
7 +
8 + -# old style
2 9 = error_messages_for :announcement
3 10 = simple_form_for(@announcement) do |f|
4 11 .row
5 12 .col-md-6
6 13 = f.input :title
7 14 = f.input :notes, label: 'Notes (shown internally, used to organize announcements)'
@@ -9,6 +16,7
9 16 = f.input :author
10 17 = f.input :published
11 18 = f.input :frontpage, label: 'Display in the front page only?'
12 19 = f.input :contest_only, label: 'Display in contest only?'
13 20 = f.button :submit, "Create", class: 'btn btn-primary'
14 21 = link_to 'Back', announcements_path, class: 'btn btn-default'
22 +
@@ -14,11 +14,14
14 14 %b Published:
15 15 = h @announcement.published
16 16 %p
17 17 %b Show on front page:
18 18 = h @announcement.frontpage
19 19 %p
20 + %b Show on top menu bar:
21 + = h @announcement.on_nav_bar
22 + %p
20 23 %b Show only in contest:
21 24 = h @announcement.contest_only
22 25 = link_to 'Edit', edit_announcement_path(@announcement)
23 26 |
24 27 = link_to 'Back', announcements_path
@@ -67,12 +67,18
67 67 = add_menu( 'Submission Report', 'report', 'submission')
68 68 = add_menu( 'Login Report', 'report', 'login')
69 69 - if (ungraded = Submission.where('graded_at is null').where('submitted_at < ?', 1.minutes.ago).count) > 0
70 70 =link_to "#{ungraded} backlogs!",
71 71 graders_list_path,
72 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 80 %ul.nav.navbar-nav.navbar-right
75 81 = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-question-sign')}".html_safe, 'main', 'help')
76 82 = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-comment')}".html_safe, 'messages', 'index', {title: I18n.t('menu.messages'), data: {toggle: 'tooltip'}})
77 83 - if GraderConfiguration['system.user_setting_enabled']
78 84 = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-cog', id: 'user_profile')}".html_safe, 'users', 'profile', {title: I18n.t('menu.settings'), data: {toggle: 'tooltip'}})
@@ -7,24 +7,25
7 7 # system, you should be using db:schema:load, not running all the migrations
8 8 # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9 9 # you'll amass, the slower it'll run and the greater likelihood for issues).
10 10 #
11 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 15 create_table "announcements", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
16 16 t.string "author"
17 17 t.text "body"
18 18 t.boolean "published"
19 19 t.datetime "created_at", null: false
20 20 t.datetime "updated_at", null: false
21 21 t.boolean "frontpage", default: false
22 22 t.boolean "contest_only", default: false
23 23 t.string "title"
24 24 t.string "notes"
25 + t.boolean "on_nav_bar", default: false
25 26 end
26 27
27 28 create_table "contests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
28 29 t.string "title"
29 30 t.boolean "enabled"
30 31 t.datetime "created_at", null: false
You need to be logged in to leave comments. Login now