Skip to content

Commit

Permalink
Merge branch 'dev' into flexibus/#380/events-view-as-tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
Blubl authored Feb 8, 2018
2 parents d9a909f + b0a6153 commit 83cdec1
Show file tree
Hide file tree
Showing 54 changed files with 574 additions and 332 deletions.
8 changes: 3 additions & 5 deletions app/assets/javascripts/eventscripts/create_event.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,12 @@ $( document ).on('turbolinks:load', function() {
{
case "elo":
$("#rankinglist_initial_value").val(initial_value_elo);
$("#default_point_distribution").hide();
var default_elo_change = $("#rankinglist_maximum_elo_change");
if(default_elo_change.val() == "")
if(default_elo_change.val()=="")
{
default_elo_change.val(32);
}
$("#elo_point_distribution").show();
$("#rankinglist_advanced").show();
break;
case "true_skill":
$("#rankinglist_initial_value").val(initial_value_trueskill);
Expand All @@ -120,8 +119,7 @@ $( document ).on('turbolinks:load', function() {
break;
default:
$("#rankinglist_initial_value").val("0");
$("#default_point_distribution").show();
$("#elo_point_distribution").hide();
$("#rankinglist_advanced").hide();
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/events.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ form.event {
flex-direction:column;
}

#event-erweitert {
#event_advanced,#rankinglist_advanced {
width:100%;
}

Expand Down
8 changes: 7 additions & 1 deletion app/assets/stylesheets/teams.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ select.filterSelect {
display: block;
}
/* Overwrite container from application.html.erb for background image only*/
body > .background-layer > .container {
body > .background > .container {
width: 100%;
max-width: 100% !important;
padding: 0 0;
}

.background > nav {
background-color: #0f3157 !important;
}

#teamProfile {
background-size: cover;
background-position: bottom center;
Expand All @@ -41,11 +45,13 @@ body > .background-layer > .container {
#teamProfileImage {
width: 200px;
height: 200px;
object-fit: cover;
}

#teamDescription {
overflow: hidden;
word-wrap: break-word;
font-size: 1.4rem;
}

h1, h2 {
Expand Down
9 changes: 5 additions & 4 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ def edit
# POST /events
def create
@event = event_type.new(event_params)
@event.matchtype = :bestof
@event.min_players_per_team = 1
@event.max_players_per_team = 1
set_associations
if @event.save
@event.editors << current_user
Expand Down Expand Up @@ -65,7 +62,7 @@ def join
else
@event.add_team(Team.find(event_params[:teams]))
end

flash[:success] = t('success.join_event', event: @event.name)
redirect_back fallback_location: events_url
end
Expand Down Expand Up @@ -112,6 +109,10 @@ def set_event
end

def set_associations
@event.matchtype ||= :bestof
@event.game_winrule ||= :most_sets
@event.min_players_per_team ||= 1
@event.max_players_per_team ||= 1
@event.owner = current_user
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/gamedays_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class GamedaysController < ApplicationController
def update
@gameday = Gameday.find(params[:id])
authorize! :update, @gameday
if @gameday.update(starttime: Date.strptime(gameday_params[:starttime],'%d.%m.%Y'), endtime: Date.strptime(gameday_params[:endtime], '%d.%m.%Y'))
if @gameday.update(starttime: Date.strptime(gameday_params[:starttime], '%d.%m.%Y'), endtime: Date.strptime(gameday_params[:endtime], '%d.%m.%Y'))
redirect_to event_schedule_path(@gameday.event), notice: t('success.updated_gameday_dates')
end
end
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/matches_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class MatchesController < ApplicationController
before_action :set_match, only: [:show, :edit, :update, :update_points, :edit_results, :update_results, :destroy, :add_game_result, :remove_game_result]
authorize_resource only: [:edit]
authorize_resource only: [:edit, :destroy]

# GET /matches/1
def show
Expand Down Expand Up @@ -79,7 +79,6 @@ def remove_game_result
render :edit_results
end


# DELETE /matches/1
def destroy
@match.destroy
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ def self.unimportant_changes?(resource, params)
# Overridden methods of `Devise::RegistrationsController` to permit additional model params
def sign_up_params
generate_random_password if get_omniauth_data
params.require(:user).permit(:first_name, :last_name, :email, :password, :image, :remove_image, :password_confirmation, :avatar, :remove_avatar, :birthday, :telephone_number, :telegram_username, :favourite_sports, :team_notifications_enabled, :event_notifications_enabled, event_ids: [])
params.require(:user).permit(:first_name, :last_name, :email, :password, :image, :remove_image, :password_confirmation, :avatar, :remove_avatar, :birthday, :telephone_number, :telegram_username, :favourite_sports, :contact_information, :team_notifications_enabled, :event_notifications_enabled, event_ids: [])
end

def account_update_params
params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation, :current_password, :avatar, :remove_avatar, :birthday, :telephone_number, :telegram_username, :favourite_sports, :team_notifications_enabled, :event_notifications_enabled, event_ids: [])
params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation, :current_password, :avatar, :remove_avatar, :birthday, :telephone_number, :telegram_username, :favourite_sports, :contact_information, :team_notifications_enabled, :event_notifications_enabled, event_ids: [])
end

def admin_update_params
Expand Down
12 changes: 11 additions & 1 deletion app/mailers/match_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@ def send_mail(user, match, template)
@user = user
@match = match

team_home = match.team_home
team_away = match.team_away
opponent_team = (team_home.has_member? user) ? team_away : team_home
@opponent_team = opponent_team

subject = t("match_mailer.#{template}.subject",
opponent_team_name: opponent_team.name,
event_name: match.event.name)

mail(to: user.email,
subject: t("match_mailer.#{template}.subject")) do |format|
subject: subject) do |format|
format.html { render template }
format.text { render template }
end

prevent_delivery_to_event_unsubscribed_users(user)
end
end
1 change: 0 additions & 1 deletion app/mailers/team_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ def team_registered_to_event(user, team, event)
event_name: @event.name)
prevent_delivery_to_team_unsubscribed_users(user)
end

end
1 change: 1 addition & 0 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def initialize_with_user(user)

# Match
can_modify_match(user)
cannot :destroy, Match

if user.admin?
can :manage, :all
Expand Down
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# telephone_number :string
# telegram_username :string
# favourite_sports :string
# contact_information :string
# provider :string
# uid :string
# avatar_data :text
Expand Down
7 changes: 7 additions & 0 deletions app/views/application/_background.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
end
when "welcome"
$background = $new_background
when "teams"
case action_name
when "show"
$background = $new_background
else
$background = $no_background
end
else
$background = $no_background
end
Expand Down
6 changes: 6 additions & 0 deletions app/views/devise/registrations/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
<p class="description-text"><%= @user.favourite_sports %></p>
<% end %>
</div>
<div class="row">
<% if @user.contact_information.present? %>
<p class="description-tag"><%= model_class.human_attribute_name(:contact_information) %></p>
<p class="description-text"><%= @user.contact_information %></p>
<% end %>
</div>
<div class="row">
<% if can? :edit, @user %>
<%= link_to t('.edit', :default => t('navbar.drop-down.edit_profile')),
Expand Down
67 changes: 0 additions & 67 deletions app/views/events/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -60,73 +60,6 @@
<%# Rendering the correct template depending on the event type %>
<%= render "events/forms/#{@event.model_name}", form: f %>

<div class="form-group order-6">
<div class="col-lg-12">
<button class="btn btn-primary" id="event-erweitert" type="button" data-toggle="collapse" data-target="#collapseAdvancedOptions" aria-expanded="false" aria-controls="collapseAdvancedOptions">
<%= t('events.advanced') %>
</button>

<div class="collapse" id="collapseAdvancedOptions">
<div class="form-group">
<%= f.label :bestof_length, for: :matchtype, class: 'control-label col-lg-2', data: {toggle: "tooltip", placement: "right" }, title: t('events.winrule_tooltip') %>
<div id="matchtype" class="col-lg-10">
<%= t('events.best_of') %>
<%= f.select(:bestof_length, (1..8).map { |n| ["#{n}", n] },
{ selected: f.object.bestof_length },
{ class: 'form-control'}) %>
</div>
</div>

<div class="form-group">
<%= f.label :game_winrule, for: :game_winrule, :class => 'control-label col-lg-2' %>
<div class="col-lg-10">
<%= f.select(:game_winrule, Event.game_winrules.map {|k, v| [k.humanize, k]},
{ selected: f.object.game_winrule },
{ class: 'form-control' }) %>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">
<%= t('view.event.point_distribution') %>
</div>
<div class="panel-body" id="default_point_distribution">
<div class="form-group">
<%= f.label :points_for_win, :class => 'control-label col-lg-2' %>
<div class="col-lg-10">
<%= f.number_field :points_for_win, in: 0..2e9, step: 1, :class => 'form-control',:style=> 'width:60px', :value=> f.object.points_for_win %>
</div>
</div>

<div class="form-group">
<%= f.label :points_for_draw, :class => 'control-label col-lg-2' %>
<div class="col-lg-10">
<%= f.number_field :points_for_draw, in: 0..2e9, step: 1, :class => 'form-control' ,:style=> 'width:60px', :value=> f.object.points_for_draw %>
</div>
</div>

<div class="form-group">
<%= f.label :points_for_lose, :class => 'control-label col-lg-2' %>
<div class="col-lg-10">
<%= f.number_field :points_for_lose, in: 0..2e9, step: 1, :class => 'form-control',:style=> 'width:60px', :value=> f.object.points_for_lose %>
</div>
</div>
</div>
<div class="panel-body" id="elo_point_distribution">
<div class="form-group">
<%= f.label :maximum_elo_change, :class => 'control-label col-lg-2' %>
<div class="col-lg-10">
<%= f.number_field :maximum_elo_change, in: 1..2e9, step: 1, :class => 'form-control',:style=> 'width:60px', :value=> f.object.maximum_elo_change %>
</div>
</div>
</div>
</div>

</div>
</div>
</div>


<div class="form-group order-7">
<div class="col-lg-offset-2 col-lg-10">
<%= f.submit nil,
Expand Down
13 changes: 12 additions & 1 deletion app/views/events/_schedule_league.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,19 @@
<% end %>
</td>
<td>
<%= link_to t('events.schedule.insert_results'),
<%= link_to t('.show', default: t('helpers.links.show')),
match_path(match), :class => 'btn btn-default btn-xs' %>
<% if can? :edit, match %>
<%= link_to t('.edit', default: t('helpers.links.edit')),
edit_match_path(match), :class => 'btn btn-default btn-xs' %>
<% end %>
<% if can? :destroy, match %>
<%= link_to t('.destroy', default: t('helpers.links.destroy')),
match_path(match),
:method => :delete,
:data => { :confirm => t('.confirm', default: t('helpers.links.confirm')) },
:class => 'btn btn-xs btn-danger' %>
<% end %>
</td>
</tr>
<% end %>
Expand Down
13 changes: 12 additions & 1 deletion app/views/events/_schedule_tournament.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,19 @@
<% end %>
</td>
<td>
<%= link_to t('events.schedule.insert_results'),
<%= link_to t('.show', default: t('helpers.links.show')),
match_path(match), :class => 'btn btn-default btn-xs' %>
<% if can? :edit, match %>
<%= link_to t('.edit', default: t('helpers.links.edit')),
edit_match_path(match), :class => 'btn btn-default btn-xs' %>
<% end %>
<% if can? :destroy, match %>
<%= link_to t('.destroy', default: t('helpers.links.destroy')),
match_path(match),
:method => :delete,
:data => { :confirm => t('.confirm', default: t('helpers.links.confirm')) },
:class => 'btn btn-xs btn-danger' %>
<% end %>
</td>
</tr>
<% end %>
Expand Down
5 changes: 2 additions & 3 deletions app/views/events/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script src="event.js"></script>
<%- model_class = Event -%>
<div class="page-header">
<h1><%=t '.title', :default => :'helpers.titles.edit', :model => model_class.model_name.human.titleize %></h1>
<h1><%=t '.title', default: :'helpers.titles.edit', model: @event.model_name.human.titleize %></h1>
</div>

<%= render 'form', submit_label: t('helpers.links.save'), back_path: event_path(@event) %>
12 changes: 12 additions & 0 deletions app/views/events/forms/_League.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,15 @@
<%= form.number_field :gameday_duration, class: 'form-control' %>
</div>
</div>

<div class="form-group order-6">
<div class="col-lg-12">
<button class="btn btn-primary" id="event_advanced" type="button" data-toggle="collapse" data-target="#collapseAdvancedOptions" aria-expanded="false" aria-controls="collapseAdvancedOptions">
<%= t('events.advanced') %>
</button>

<div class="collapse" id="collapseAdvancedOptions">
<%= render 'events/forms/parts/advanced_options', form: form %>
</div>
</div>
</div>
24 changes: 24 additions & 0 deletions app/views/events/forms/_Rankinglist.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,27 @@
<%= form.text_field :initial_value, class: 'form-control' %>
</div>
</div>

<div class="form-group order-6" id="rankinglist_advanced">
<div class="col-lg-12">
<button class="btn btn-primary" id="event_advanced" type="button" data-toggle="collapse" data-target="#collapseAdvancedOptions" aria-expanded="false" aria-controls="collapseAdvancedOptions">
<%= t('events.advanced') %>
</button>

<div class="collapse" id="collapseAdvancedOptions">
<div class="panel panel-default">
<div class="panel-heading">
<%= t('view.event.point_distribution') %>
</div>
<div class="panel-body">
<div class="form-group">
<%= form.label :maximum_elo_change, :class => 'control-label col-lg-2' %>
<div class="col-lg-10">
<%= form.number_field :maximum_elo_change, in: 1..2e9, step: 1, :class => 'form-control',:style=> 'width:60px', :value=> form.object.maximum_elo_change %>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
12 changes: 12 additions & 0 deletions app/views/events/forms/_Tournament.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,15 @@
<%= form.label :has_place_3_match %>
</div>
</div>

<div class="form-group order-6">
<div class="col-lg-12">
<button class="btn btn-primary" id="event-erweitert" type="button" data-toggle="collapse" data-target="#collapseAdvancedOptions" aria-expanded="false" aria-controls="collapseAdvancedOptions">
<%= t('events.advanced') %>
</button>

<div class="collapse" id="collapseAdvancedOptions">
<%= render 'events/forms/parts/advanced_options', form: form %>
</div>
</div>
</div>
Loading

0 comments on commit 83cdec1

Please sign in to comment.