From 5d4132ccbf0756df4a0df2ce0c2c098ff71ae2f8 Mon Sep 17 00:00:00 2001 From: Ari Timonen Date: Wed, 18 Mar 2020 21:41:54 +0200 Subject: [PATCH] Fix link_to_function in contesters Fix params for comment and message Fix tinymce errors --- app/controllers/comments_controller.rb | 2 +- app/controllers/contesters_controller.rb | 2 +- app/models/comment.rb | 2 +- app/models/contester.rb | 2 +- app/models/message.rb | 2 +- app/views/contests/edit.html.erb | 508 +++++++++++------------ config/tinymce.yml | 2 - 7 files changed, 259 insertions(+), 261 deletions(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index ee6e034..76fa173 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -16,7 +16,7 @@ class CommentsController < ApplicationController end def create - @comment = Comment.new Comment.params(parmas, cuser) + @comment = Comment.new(Comment.params(params, cuser)) @comment.user = cuser raise AccessError unless @comment.can_create? cuser diff --git a/app/controllers/contesters_controller.rb b/app/controllers/contesters_controller.rb index 4d7b233..26a3e20 100644 --- a/app/controllers/contesters_controller.rb +++ b/app/controllers/contesters_controller.rb @@ -50,7 +50,7 @@ class ContestersController < ApplicationController if @contester.update_attributes(Contester.params(params, cuser)) flash[:notice] = t(:contests_contester_update) - redirect_to @contester.contest + redirect_to_back else render :edit end diff --git a/app/models/comment.rb b/app/models/comment.rb index feae503..add3cf8 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -67,6 +67,6 @@ class Comment < ActiveRecord::Base end def self.params params, cuser - params.require(:ban).permit(:text, :user_id, :commentable_type, :commentable_id) + params.require(:comment).permit(:text, :user_id, :commentable_type, :commentable_id) end end diff --git a/app/models/contester.rb b/app/models/contester.rb index f2f25ec..306864f 100644 --- a/app/models/contester.rb +++ b/app/models/contester.rb @@ -128,6 +128,6 @@ class Contester < ActiveRecord::Base end def self.params params, cuser - params.require(:contester).permit(:team_id, :score, :win, :lowss, :draw, :contest_id, :active, :extra) + params.require(:contester).permit(:team_id, :score, :win, :lowss, :draw, :contest_id, :active, :extra, :user) end end diff --git a/app/models/message.rb b/app/models/message.rb index 6edad89..bd58efb 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -98,6 +98,6 @@ class Message < ActiveRecord::Base def self.params(params, cuser) # FIXME: check this - params.require(:message).permit(:recipient_type, :sender_type, :title, :text, :recipient_id, :sender_id) + params.require(:message).permit(:recipient_type, :sender_type, :title, :text, :recipient_id, :sender_id, :sender_raw) end end diff --git a/app/views/contests/edit.html.erb b/app/views/contests/edit.html.erb index bee8782..1317410 100644 --- a/app/views/contests/edit.html.erb +++ b/app/views/contests/edit.html.erb @@ -1,272 +1,272 @@

Editing Contest

- - -
-
- <%= form_for @contest, html: { class: 'square' } do |f| %> - <%= render 'shared/errors', messages: @contest.errors.full_messages %> - <%= hidden_field_tag :type, 'contest' %> - -
- <%= f.label :name %> - <%= f.text_field :name %> -
-
- <%= f.label :short_name %> - <%= f.text_field :short_name %> -
-
- <%= f.label :start %> - <%= f.datetime_select :start, datetime_separator: '', time_separator: '' %> -
-
- <%= f.label :end %> - <%= f.datetime_select :end, datetime_separator: '', time_separator: '' %> -
-
- <%= f.label :status %> - <%= f.select :status, @contest.statuses.invert %> -
-
- <%= f.label :demos_id %> - <%= f.select :demos_id, Directory.all.collect{|d| [d, d.id]} %> -
-
- <%= f.label :default_time %> - <%= f.time_select :default_time, time_separator: '' %> -
-
- <%= f.label :winner_id %> - <%= f.select :winner_id, @contest.contesters.collect { |t| [t.team, t.id] }, include_blank: true %> -
-
- <%= f.label :rules_id %> - <%= f.select :rules_id, Category.find(Category::RULES).articles.collect { |a| [a, a.id] }, include_blank: true %> -
- - <% if @contest.contest_type == Contest::TYPE_LADDER %> -
- <%= f.label :weight %> - <%= f.text_field :weight %> -
-
- <%= f.label :modulus_base %> - <%= f.text_field :modulus_base %> -
-
- <%= f.label :modulus_even %> - <%= f.text_field :modulus_even %> -
-
- <%= f.label :modulus_3to1 %> - <%= f.text_field :modulus_3to1 %> -
-
- <%= f.label :modulus_4to0 %> - <%= f.text_field :modulus_4to0 %> -
+ -
- <%= f.submit 'Save Contest' %> +
+
+ <%= form_for @contest, html: { class: 'square' } do |f| %> + <%= render 'shared/errors', messages: @contest.errors.full_messages %> + <%= hidden_field_tag :type, 'contest' %> + +
+ <%= f.label :name %> + <%= f.text_field :name %> +
+
+ <%= f.label :short_name %> + <%= f.text_field :short_name %> +
+
+ <%= f.label :start %> + <%= f.datetime_select :start, datetime_separator: '', time_separator: '' %> +
+
+ <%= f.label :end %> + <%= f.datetime_select :end, datetime_separator: '', time_separator: '' %> +
+
+ <%= f.label :status %> + <%= f.select :status, @contest.statuses.invert %> +
+
+ <%= f.label :demos_id %> + <%= f.select :demos_id, Directory.all.collect{|d| [d, d.id]} %> +
+
+ <%= f.label :default_time %> + <%= f.time_select :default_time, time_separator: '' %> +
+
+ <%= f.label :winner_id %> + <%= f.select :winner_id, @contest.contesters.collect { |t| [t.team, t.id] }, include_blank: true %> +
+
+ <%= f.label :rules_id %> + <%= f.select :rules_id, Category.find(Category::RULES).articles.collect { |a| [a, a.id] }, include_blank: true %> +
+ + <% if @contest.contest_type == Contest::TYPE_LADDER %> +
+ <%= f.label :weight %> + <%= f.text_field :weight %> +
+
+ <%= f.label :modulus_base %> + <%= f.text_field :modulus_base %> +
+
+ <%= f.label :modulus_even %> + <%= f.text_field :modulus_even %> +
+
+ <%= f.label :modulus_3to1 %> + <%= f.text_field :modulus_3to1 %> +
+
+ <%= f.label :modulus_4to0 %> + <%= f.text_field :modulus_4to0 %> +
+ <% end %> + +
+ <%= f.submit 'Save Contest' %> +
+ <% end %>
- <% end %> -
- <% if @contest.contest_type == Contest::TYPE_BRACKET %> -
- - - - - - + <% if @contest.contest_type == Contest::TYPE_BRACKET %> +
+
BracketSlots
+ + + + + - <% @contest.brackets.each do |bracket| %> - - - - - - <% end %> -
BracketSlots
<%= namelink bracket %><%= bracket.slots %> - <%= link_to icon('pencil'), edit_bracket_path(bracket) %> - <%= link_to icon('times'), bracket, confirm: 'Are you sure?', method: :delete %> -
- - <%= form_for @contest.brackets.build, html: { class: 'square' } do |f| %> - <%= render 'shared/errors', messages: @contest.brackets.last.errors.full_messages %> - <%= hidden_field_tag :type, 'contest' %> - - <%= f.hidden_field :contest_id %> - -
- <%= f.label :slots %> - <%= f.text_field :slots %> -
-
- <%= f.submit 'Add Bracket' %> -
- <% end %> -
- <% end %> - -
- - - - - - - - <% @contest.maps.basic.each do |map| %> - - - - - - <% end %> -
NameDownload
<%= namelink map %><%= h map.download %> - <%= link_to icon('pencil'), edit_map_path(map) %> - <%= link_to icon('times'), action: "del_map", id: @contest.id, id2: map.id %> -
- - <%= form_for @contest do |f| %> - <%= render 'shared/errors', messages: @contest.errors.full_messages %> - <%= hidden_field_tag :type, 'map' %> - -
- <%= select_tag :map, options_from_collection_for_select(Map.basic, :id, :name) %> -
-
- <%= f.submit 'Add map' %> -
- <% end %> -
- -
- - - - - - - - - <% @contest.contesters.each do |contester| %> - - - - - + + + + <% end %> - <% end %> - - - <% end %> -
TeamScoreStatus
<%= link_to (h contester.team), contester %><%= h contester.score %><%= contester.statuses[contester.active] %> - <% if contester.active %> - <%= link_to icon('pencil'), edit_contester_path(contester) %> - <%= link_to icon('times'), contester, confirm: 'Are you sure?', method: :delete %> - <% else %> - <%= form_for contester do |c| %> - <%= c.hidden_field :active, { value: 1 } %> - <%= link_to icon('pencil'), edit_contester_path(contester) %> - <%= link_to_function icon('rotate-left'), "$('#edit_contester_#{contester.id}').submit()" %> + <% @contest.brackets.each do |bracket| %> +
<%= namelink bracket %><%= bracket.slots %> + <%= link_to icon('pencil'), edit_bracket_path(bracket) %> + <%= link_to icon('times'), bracket, confirm: 'Are you sure?', method: :delete %> +
+ - <%= form_for @contest.contesters.build do |f| %> - <%= render 'shared/errors', messages: @contest.contesters.last.errors.full_messages %> - <%= hidden_field_tag :type, 'team' %> + <%= form_for @contest.brackets.build, html: { class: 'square' } do |f| %> + <%= render 'shared/errors', messages: @contest.brackets.last.errors.full_messages %> + <%= hidden_field_tag :type, 'contest' %> - <%= f.hidden_field :contest_id %> + <%= f.hidden_field :contest_id %> -
- <%= f.select :team_id, Team.active.ordered.collect{|t| [t, t.id]} %> +
+ <%= f.label :slots %> + <%= f.text_field :slots %> +
+
+ <%= f.submit 'Add Bracket' %> +
+ <% end %>
-
- <%= f.submit 'Add Team' %> + <% end %> + +
+ + + + + + + + <% @contest.maps.basic.each do |map| %> + + + + + + <% end %> +
NameDownload
<%= namelink map %><%= h map.download %> + <%= link_to icon('pencil'), edit_map_path(map) %> + <%= link_to icon('times'), action: "del_map", id: @contest.id, id2: map.id %> +
+ + <%= form_for @contest do |f| %> + <%= render 'shared/errors', messages: @contest.errors.full_messages %> + <%= hidden_field_tag :type, 'map' %> + +
+ <%= select_tag :map, options_from_collection_for_select(Map.basic, :id, :name) %> +
+
+ <%= f.submit 'Add map' %> +
+ <% end %> +
+ +
+ + + + + + + + + <% @contest.contesters.each do |contester| %> + + + + + + + <% end %> +
TeamScoreStatus
<%= link_to (h contester.team), contester %><%= h contester.score %><%= contester.statuses[contester.active] %> + <% if contester.active %> + <%= link_to icon('pencil'), edit_contester_path(contester) %> + <%= link_to icon('times'), contester, confirm: 'Are you sure?', method: :delete %> + <% else %> + <%= form_for contester do |c| %> + <%= c.hidden_field :active, { value: 1 } %> + <%= link_to icon('pencil'), edit_contester_path(contester) %> + <%= link_to icon('rotate-left'), "#form_submit" %> + <% end %> + <% end %> +
+ + <%= form_for @contest.contesters.build do |f| %> + <%= render 'shared/errors', messages: @contest.contesters.last.errors.full_messages %> + <%= hidden_field_tag :type, 'team' %> + + <%= f.hidden_field :contest_id %> + +
+ <%= f.select :team_id, Team.active.ordered.collect{|t| [t, t.id]} %> +
+
+ <%= f.submit 'Add Team' %> +
+ <% end %> +
+ +
+ + + + + + + + + + <% @contest.weeks.each do |week| %> + + + + + + + + <% end %> +
NameStart dateMap1Map2
<%= h week.name %><%= week.start_date.strftime("%d %B %y") %><%= h week.map1 %><%= h week.map2 %> + <%= link_to icon('pencil'), edit_week_path(week) %> + <%= link_to icon('times'), week, confirm: 'Are you sure?', method: :delete %> +
+ + <%= link_to "New Week", { controller: :weeks, action: :new, id: @contest }, { class: 'button' } %> +
+ +
+ + + + + + + + + <% @contest.matches.each do |match| %> + + + + + + + <% end %> +
TeamsDateScore
+ <%= namelink match.contester1.team %> + vs + <%= namelink match.contester2.team %> + + <%= longtime match.match_time %> + + <% link_to match do %> + <%= h match.score1 %> - <%= h match.score2 %> + <% end %> + + <%= link_to icon('flag-checkered'), controller: :matches, action: :ref, id: match %> + <%= link_to icon('pencil'), edit_match_path(match) %> + <%= link_to icon('times'), match, confirm: 'Are you sure?', method: :delete %> +
+ + <%= link_to "New Match", { controller: :matches, action: :new, id: @contest }, { class: 'button' } %>
- <% end %>
- -
- - - - - - - - - - <% @contest.weeks.each do |week| %> - - - - - - - - <% end %> -
NameStart dateMap1Map2
<%= h week.name %><%= week.start_date.strftime("%d %B %y") %><%= h week.map1 %><%= h week.map2 %> - <%= link_to icon('pencil'), edit_week_path(week) %> - <%= link_to icon('times'), week, confirm: 'Are you sure?', method: :delete %> -
- - <%= link_to "New Week", { controller: :weeks, action: :new, id: @contest }, { class: 'button' } %> -
- -
- - - - - - - - - <% @contest.matches.each do |match| %> - - - - - - - <% end %> -
TeamsDateScore
- <%= namelink match.contester1.team %> - vs - <%= namelink match.contester2.team %> - - <%= longtime match.match_time %> - - <% link_to match do %> - <%= h match.score1 %> - <%= h match.score2 %> - <% end %> - - <%= link_to icon('flag-checkered'), controller: :matches, action: :ref, id: match %> - <%= link_to icon('pencil'), edit_match_path(match) %> - <%= link_to icon('times'), match, confirm: 'Are you sure?', method: :delete %> -
- - <%= link_to "New Match", { controller: :matches, action: :new, id: @contest }, { class: 'button' } %> -
-
+ new Yetii({ + id: 'contest' + }); + \ No newline at end of file diff --git a/config/tinymce.yml b/config/tinymce.yml index 82127ca..ffedd90 100644 --- a/config/tinymce.yml +++ b/config/tinymce.yml @@ -11,8 +11,6 @@ articles: # mode: "textareas", #theme: "modern" plugins: - - inlinepopups - - contextmenu - nonbreaking - template # theme_advanced_buttons1: "bold,italic,blockquote,|,bullist,numlist,|,formatselect,|,link,unlink,image,|,cleanup,code",