Fix link_to_function in contesters

Fix params for comment and message
Fix tinymce errors
This commit is contained in:
Ari Timonen 2020-03-18 21:41:54 +02:00
parent c97a47ffda
commit 5d4132ccbf
7 changed files with 259 additions and 261 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,272 +1,272 @@
<h1 class="title">Editing Contest</h1>
<div id="contest" class="contest-manage tabbed">
<ul id="contest-nav" class="tabs">
<li><a href="#general">General</a></li>
<% if @contest.contest_type == Contest::TYPE_BRACKET %>
<li><a href="#brackets">Brackets</a></li>
<% end %>
<li><a href="#maps">Maps</a></li>
<li><a href="#teams">Teams</a></li>
<li><a href="#weeks">Weeks</a></li>
<li><a href="#matches">Matches</a></li>
</ul>
<div class="tabbed-contents">
<div class="tab" id="general">
<%= form_for @contest, html: { class: 'square' } do |f| %>
<%= render 'shared/errors', messages: @contest.errors.full_messages %>
<%= hidden_field_tag :type, 'contest' %>
<div class="fields horizontal">
<%= f.label :name %>
<%= f.text_field :name %>
</div>
<div class="fields horizontal">
<%= f.label :short_name %>
<%= f.text_field :short_name %>
</div>
<div class="fields horizontal">
<%= f.label :start %>
<%= f.datetime_select :start, datetime_separator: '', time_separator: '' %>
</div>
<div class="fields horizontal">
<%= f.label :end %>
<%= f.datetime_select :end, datetime_separator: '', time_separator: '' %>
</div>
<div class="fields horizontal">
<%= f.label :status %>
<%= f.select :status, @contest.statuses.invert %>
</div>
<div class="fields horizontal">
<%= f.label :demos_id %>
<%= f.select :demos_id, Directory.all.collect{|d| [d, d.id]} %>
</div>
<div class="fields horizontal">
<%= f.label :default_time %>
<%= f.time_select :default_time, time_separator: '' %>
</div>
<div class="fields horizontal">
<%= f.label :winner_id %>
<%= f.select :winner_id, @contest.contesters.collect { |t| [t.team, t.id] }, include_blank: true %>
</div>
<div class="fields horizontal">
<%= f.label :rules_id %>
<%= f.select :rules_id, Category.find(Category::RULES).articles.collect { |a| [a, a.id] }, include_blank: true %>
</div>
<% if @contest.contest_type == Contest::TYPE_LADDER %>
<div class="fields horizontal">
<%= f.label :weight %>
<%= f.text_field :weight %>
</div>
<div class="fields horizontal">
<%= f.label :modulus_base %>
<%= f.text_field :modulus_base %>
</div>
<div class="fields horizontal">
<%= f.label :modulus_even %>
<%= f.text_field :modulus_even %>
</div>
<div class="fields horizontal">
<%= f.label :modulus_3to1 %>
<%= f.text_field :modulus_3to1 %>
</div>
<div class="fields horizontal">
<%= f.label :modulus_4to0 %>
<%= f.text_field :modulus_4to0 %>
</div>
<ul id="contest-nav" class="tabs">
<li><a href="#general">General</a></li>
<% if @contest.contest_type == Contest::TYPE_BRACKET %>
<li><a href="#brackets">Brackets</a></li>
<% end %>
<li><a href="#maps">Maps</a></li>
<li><a href="#teams">Teams</a></li>
<li><a href="#weeks">Weeks</a></li>
<li><a href="#matches">Matches</a></li>
</ul>
<div class="controls">
<%= f.submit 'Save Contest' %>
<div class="tabbed-contents">
<div class="tab" id="general">
<%= form_for @contest, html: { class: 'square' } do |f| %>
<%= render 'shared/errors', messages: @contest.errors.full_messages %>
<%= hidden_field_tag :type, 'contest' %>
<div class="fields horizontal">
<%= f.label :name %>
<%= f.text_field :name %>
</div>
<div class="fields horizontal">
<%= f.label :short_name %>
<%= f.text_field :short_name %>
</div>
<div class="fields horizontal">
<%= f.label :start %>
<%= f.datetime_select :start, datetime_separator: '', time_separator: '' %>
</div>
<div class="fields horizontal">
<%= f.label :end %>
<%= f.datetime_select :end, datetime_separator: '', time_separator: '' %>
</div>
<div class="fields horizontal">
<%= f.label :status %>
<%= f.select :status, @contest.statuses.invert %>
</div>
<div class="fields horizontal">
<%= f.label :demos_id %>
<%= f.select :demos_id, Directory.all.collect{|d| [d, d.id]} %>
</div>
<div class="fields horizontal">
<%= f.label :default_time %>
<%= f.time_select :default_time, time_separator: '' %>
</div>
<div class="fields horizontal">
<%= f.label :winner_id %>
<%= f.select :winner_id, @contest.contesters.collect { |t| [t.team, t.id] }, include_blank: true %>
</div>
<div class="fields horizontal">
<%= f.label :rules_id %>
<%= f.select :rules_id, Category.find(Category::RULES).articles.collect { |a| [a, a.id] }, include_blank: true %>
</div>
<% if @contest.contest_type == Contest::TYPE_LADDER %>
<div class="fields horizontal">
<%= f.label :weight %>
<%= f.text_field :weight %>
</div>
<div class="fields horizontal">
<%= f.label :modulus_base %>
<%= f.text_field :modulus_base %>
</div>
<div class="fields horizontal">
<%= f.label :modulus_even %>
<%= f.text_field :modulus_even %>
</div>
<div class="fields horizontal">
<%= f.label :modulus_3to1 %>
<%= f.text_field :modulus_3to1 %>
</div>
<div class="fields horizontal">
<%= f.label :modulus_4to0 %>
<%= f.text_field :modulus_4to0 %>
</div>
<% end %>
<div class="controls">
<%= f.submit 'Save Contest' %>
</div>
<% end %>
</div>
<% end %>
</div>
<% if @contest.contest_type == Contest::TYPE_BRACKET %>
<div class="tab" id="brackets">
<table class="brackets-list striped">
<tr>
<th class="bracket">Bracket</th>
<th class="slots">Slots</th>
<th class="actions"></th>
</tr>
<% if @contest.contest_type == Contest::TYPE_BRACKET %>
<div class="tab" id="brackets">
<table class="brackets-list striped">
<tr>
<th class="bracket">Bracket</th>
<th class="slots">Slots</th>
<th class="actions"></th>
</tr>
<% @contest.brackets.each do |bracket| %>
<tr>
<td><%= namelink bracket %></td>
<td><%= bracket.slots %></td>
<td class="actions">
<%= link_to icon('pencil'), edit_bracket_path(bracket) %>
<%= link_to icon('times'), bracket, confirm: 'Are you sure?', method: :delete %>
</td>
</tr>
<% end %>
</table>
<%= 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 %>
<div class="fields horizontal">
<%= f.label :slots %>
<%= f.text_field :slots %>
</div>
<div class="controls">
<%= f.submit 'Add Bracket' %>
</div>
<% end %>
</div>
<% end %>
<div class="tab" id="maps">
<table class="maps striped">
<tr>
<th class="name">Name</th>
<th class="download">Download</th>
<th class="actions"></th>
</tr>
<% @contest.maps.basic.each do |map| %>
<tr>
<td><%= namelink map %></td>
<td><%= h map.download %></td>
<td class="actions">
<%= link_to icon('pencil'), edit_map_path(map) %>
<%= link_to icon('times'), action: "del_map", id: @contest.id, id2: map.id %>
</td>
</tr>
<% end %>
</table>
<%= form_for @contest do |f| %>
<%= render 'shared/errors', messages: @contest.errors.full_messages %>
<%= hidden_field_tag :type, 'map' %>
<div class="fields">
<%= select_tag :map, options_from_collection_for_select(Map.basic, :id, :name) %>
</div>
<div class="controls">
<%= f.submit 'Add map' %>
</div>
<% end %>
</div>
<div class="tab" id="teams">
<table class="teams striped">
<tr>
<th class="team">Team</th>
<th class="score">Score</th>
<th class="status">Status</th>
<th class="actions"></th>
</tr>
<% @contest.contesters.each do |contester| %>
<tr>
<td><%= link_to (h contester.team), contester %></td>
<td><%= h contester.score %></td>
<td><%= contester.statuses[contester.active] %></td>
<td class="actions">
<% 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| %>
<tr>
<td><%= namelink bracket %></td>
<td><%= bracket.slots %></td>
<td class="actions">
<%= link_to icon('pencil'), edit_bracket_path(bracket) %>
<%= link_to icon('times'), bracket, confirm: 'Are you sure?', method: :delete %>
</td>
</tr>
<% end %>
<% end %>
</td>
</tr>
<% end %>
</table>
</table>
<%= 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 %>
<div class="fields">
<%= f.select :team_id, Team.active.ordered.collect{|t| [t, t.id]} %>
<div class="fields horizontal">
<%= f.label :slots %>
<%= f.text_field :slots %>
</div>
<div class="controls">
<%= f.submit 'Add Bracket' %>
</div>
<% end %>
</div>
<div class="controls">
<%= f.submit 'Add Team' %>
<% end %>
<div class="tab" id="maps">
<table class="maps striped">
<tr>
<th class="name">Name</th>
<th class="download">Download</th>
<th class="actions"></th>
</tr>
<% @contest.maps.basic.each do |map| %>
<tr>
<td><%= namelink map %></td>
<td><%= h map.download %></td>
<td class="actions">
<%= link_to icon('pencil'), edit_map_path(map) %>
<%= link_to icon('times'), action: "del_map", id: @contest.id, id2: map.id %>
</td>
</tr>
<% end %>
</table>
<%= form_for @contest do |f| %>
<%= render 'shared/errors', messages: @contest.errors.full_messages %>
<%= hidden_field_tag :type, 'map' %>
<div class="fields">
<%= select_tag :map, options_from_collection_for_select(Map.basic, :id, :name) %>
</div>
<div class="controls">
<%= f.submit 'Add map' %>
</div>
<% end %>
</div>
<div class="tab" id="teams">
<table class="teams striped">
<tr>
<th class="team">Team</th>
<th class="score">Score</th>
<th class="status">Status</th>
<th class="actions"></th>
</tr>
<% @contest.contesters.each do |contester| %>
<tr>
<td><%= link_to (h contester.team), contester %></td>
<td><%= h contester.score %></td>
<td><%= contester.statuses[contester.active] %></td>
<td class="actions">
<% 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 %>
</td>
</tr>
<% end %>
</table>
<%= 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 %>
<div class="fields">
<%= f.select :team_id, Team.active.ordered.collect{|t| [t, t.id]} %>
</div>
<div class="controls">
<%= f.submit 'Add Team' %>
</div>
<% end %>
</div>
<div class="tab" id="weeks">
<table class="weeks striped">
<tr>
<th class="name">Name</th>
<th class="date">Start date</th>
<th class="map1">Map1</th>
<th class="map2">Map2</th>
<th class="actions"></th>
</tr>
<% @contest.weeks.each do |week| %>
<tr>
<td><%= h week.name %></td>
<td><%= week.start_date.strftime("%d %B %y") %></td>
<td><%= h week.map1 %></td>
<td><%= h week.map2 %></td>
<td class="actions">
<%= link_to icon('pencil'), edit_week_path(week) %>
<%= link_to icon('times'), week, confirm: 'Are you sure?', method: :delete %>
</td>
</tr>
<% end %>
</table>
<%= link_to "New Week", { controller: :weeks, action: :new, id: @contest }, { class: 'button' } %>
</div>
<div class="tab" id="matches">
<table class="matches striped">
<tr>
<th class="team">Teams</th>
<th class="date">Date</th>
<th class="score">Score</th>
<th class="actions"></th>
</tr>
<% @contest.matches.each do |match| %>
<tr>
<td>
<%= namelink match.contester1.team %>
vs
<%= namelink match.contester2.team %>
</td>
<td>
<%= longtime match.match_time %>
</td>
<td>
<% link_to match do %>
<b><%= h match.score1 %> - <%= h match.score2 %></b>
<% end %>
</td>
<td class="actions">
<%= 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 %>
</td>
</tr>
<% end %>
</table>
<%= link_to "New Match", { controller: :matches, action: :new, id: @contest }, { class: 'button' } %>
</div>
<% end %>
</div>
<div class="tab" id="weeks">
<table class="weeks striped">
<tr>
<th class="name">Name</th>
<th class="date">Start date</th>
<th class="map1">Map1</th>
<th class="map2">Map2</th>
<th class="actions"></th>
</tr>
<% @contest.weeks.each do |week| %>
<tr>
<td><%= h week.name %></td>
<td><%= week.start_date.strftime("%d %B %y") %></td>
<td><%= h week.map1 %></td>
<td><%= h week.map2 %></td>
<td class="actions">
<%= link_to icon('pencil'), edit_week_path(week) %>
<%= link_to icon('times'), week, confirm: 'Are you sure?', method: :delete %>
</td>
</tr>
<% end %>
</table>
<%= link_to "New Week", { controller: :weeks, action: :new, id: @contest }, { class: 'button' } %>
</div>
<div class="tab" id="matches">
<table class="matches striped">
<tr>
<th class="team">Teams</th>
<th class="date">Date</th>
<th class="score">Score</th>
<th class="actions"></th>
</tr>
<% @contest.matches.each do |match| %>
<tr>
<td>
<%= namelink match.contester1.team %>
vs
<%= namelink match.contester2.team %>
</td>
<td>
<%= longtime match.match_time %>
</td>
<td>
<% link_to match do %>
<b><%= h match.score1 %> - <%= h match.score2 %></b>
<% end %>
</td>
<td class="actions">
<%= 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 %>
</td>
</tr>
<% end %>
</table>
<%= link_to "New Match", { controller: :matches, action: :new, id: @contest }, { class: 'button' } %>
</div>
</div>
</div>
<script type="text/javascript">
new Yetii({
id: 'contest'
});
</script>
new Yetii({
id: 'contest'
});
</script>

View file

@ -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",