diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/assets/images/baboon_cookie_icon.webp | bin | 0 -> 489794 bytes | |||
| -rw-r--r-- | app/assets/stylesheets/components/table.css | 19 | ||||
| -rw-r--r-- | app/controllers/sessions_controller.rb | 15 | ||||
| -rw-r--r-- | app/views/admin/dashboard/_scores_by_category.html.erb | 24 | 
4 files changed, 57 insertions, 1 deletions
| diff --git a/app/assets/images/baboon_cookie_icon.webp b/app/assets/images/baboon_cookie_icon.webpBinary files differ new file mode 100644 index 0000000..e822b9c --- /dev/null +++ b/app/assets/images/baboon_cookie_icon.webp diff --git a/app/assets/stylesheets/components/table.css b/app/assets/stylesheets/components/table.css new file mode 100644 index 0000000..4d09839 --- /dev/null +++ b/app/assets/stylesheets/components/table.css @@ -0,0 +1,19 @@ +table { +    width: 100%; +    border-collapse: collapse; +    font-family: monospace; +} + +table th, table td { +    border: 1px black; +    padding: 0.5rem; +} + +table th { +    background-color: tomato; +    font-weight: bold; +} + +table tbody tr { +    background-color: white; +} diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index fad2c4b..3dc076b 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,5 +1,5 @@  class SessionsController < ApplicationController -  allow_unauthenticated_access only: %i[ new create dismiss_banner ] +  allow_unauthenticated_access only: %i[ new create accept_cookies gift_nico ]    rate_limit to: 10, within: 3.minutes, only: :create, with: -> { redirect_to new_session_url, alert: "Try again later." }    def new @@ -8,6 +8,9 @@ class SessionsController < ApplicationController    def create      if user = User.authenticate_by(params.permit(:email_address, :password))        start_new_session_for user +      if user.admin +        session[:admin] = true +      end        redirect_to after_authentication_url      else        redirect_to new_session_path, alert: "Try another email address or password." @@ -23,4 +26,14 @@ class SessionsController < ApplicationController      session[:dismissed_banner] = true      redirect_to root_path    end + +  def accept_cookies +    session[:dismissed_banner] = true +    redirect_to root_path +  end + +  def gift_nico +    session[:dismissed_banner] = true +    redirect_to root_path +  end  end diff --git a/app/views/admin/dashboard/_scores_by_category.html.erb b/app/views/admin/dashboard/_scores_by_category.html.erb new file mode 100644 index 0000000..065a549 --- /dev/null +++ b/app/views/admin/dashboard/_scores_by_category.html.erb @@ -0,0 +1,24 @@ +<% ScoringCriterium.grouped_by_category.each do |category, criteria| %> +    <h3><%= category.titlecase %></h3> +    <table> +	<thead> +	    <tr> +		<th>ID</th> +		<th>Tartiflette</th> +		<th>Critère</th> +		<th>Score</th> +	    </tr> +	</thead> +	<tbody> +	    <% criteria.each do |criterium| %> +		<% criterium.scores.each do |score| %> +		    <tr> +			<td><%= score.tartiflette.scoring_id %></td> +			<td><%= score.tartiflette.name %></td> +			<td><%= criterium.name.capitalize %></td>			 +			<td><%= score.value %></td> +		<% end %> +	    <% end %> +	</tbody> +    </table> +<% end %> | 
