Compare commits
6 commits
921bfd73cc
...
0b59a74cf6
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b59a74cf6 | |||
| 507a8dfaea | |||
| 8d8bce3207 | |||
| b07b0da672 | |||
| fa57d465be | |||
| 0dd3d03b67 |
7 changed files with 86 additions and 42 deletions
|
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2025-06-08 20:44-0600\n"
|
||||
"POT-Creation-Date: 2025-10-13 20:19+0200\n"
|
||||
"PO-Revision-Date: 2025-03-29 20:41-0600\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
@ -41,11 +41,11 @@ msgstr "Bé"
|
|||
msgid "Very good"
|
||||
msgstr "Molt bé"
|
||||
|
||||
#: ../vedia.rb:119
|
||||
#: ../vedia.rb:127
|
||||
msgid "Incorrect email or password."
|
||||
msgstr "Correu o contrasenya incorrecte."
|
||||
|
||||
#: ../vedia.rb:141
|
||||
#: ../vedia.rb:149
|
||||
msgid "Reset your password"
|
||||
msgstr "Reiniciar contrasenya"
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ msgid "Description: %{description}"
|
|||
msgstr "Descripció: %{description}"
|
||||
|
||||
#: ../views/admin_votes.erb:15 ../views/votes_open.erb:3
|
||||
#: ../views/votes_show_closed.erb:4 ../views/votes_show_open.erb:4
|
||||
#: ../views/votes_show_closed.erb:4 ../views/votes_show_open.erb:12
|
||||
msgid "Closing date: %{date}"
|
||||
msgstr "Data de tancament: %{date}"
|
||||
|
||||
|
|
@ -147,7 +147,7 @@ msgstr "Estat: %{state}"
|
|||
|
||||
#: ../views/admin_votes.erb:19 ../views/votes_edit.erb:39
|
||||
#: ../views/votes_show_closed.erb:79 ../views/votes_show_draft.erb:5
|
||||
#: ../views/votes_show_open.erb:40
|
||||
#: ../views/votes_show_open.erb:54
|
||||
msgid "Organizers"
|
||||
msgstr "Organitzadores"
|
||||
|
||||
|
|
@ -193,7 +193,7 @@ msgstr "Connexió"
|
|||
|
||||
#: ../views/login.erb:9 ../views/reset.erb:5 ../views/reset_change.erb:13
|
||||
#: ../views/signup.erb:24 ../views/votes_edit.erb:51
|
||||
#: ../views/votes_show_closed.erb:99 ../views/votes_show_open.erb:66
|
||||
#: ../views/votes_show_closed.erb:99 ../views/votes_show_open.erb:80
|
||||
msgid "Email"
|
||||
msgstr "Correu"
|
||||
|
||||
|
|
@ -268,7 +268,7 @@ msgstr "Títol"
|
|||
msgid "Description"
|
||||
msgstr "Descripció"
|
||||
|
||||
#: ../views/votes_edit.erb:12 ../views/votes_show_open.erb:27
|
||||
#: ../views/votes_edit.erb:12 ../views/votes_show_open.erb:41
|
||||
msgid "Save"
|
||||
msgstr "Guardar"
|
||||
|
||||
|
|
@ -287,12 +287,12 @@ msgstr "Nom"
|
|||
|
||||
#: ../views/votes_edit.erb:47 ../views/votes_edit.erb:54
|
||||
#: ../views/votes_show_closed.erb:95 ../views/votes_show_closed.erb:102
|
||||
#: ../views/votes_show_open.erb:62 ../views/votes_show_open.erb:69
|
||||
#: ../views/votes_show_open.erb:76 ../views/votes_show_open.erb:83
|
||||
msgid "Add organizer"
|
||||
msgstr "Afegeix organitzadora"
|
||||
|
||||
#: ../views/votes_edit.erb:57 ../views/votes_show_closed.erb:89
|
||||
#: ../views/votes_show_open.erb:52
|
||||
#: ../views/votes_show_open.erb:66
|
||||
msgid "Actions for organizers"
|
||||
msgstr "Accions per les organitzadores"
|
||||
|
||||
|
|
@ -371,18 +371,22 @@ msgstr "No hi ha cap resultat perquè ningú va votar en aquesta votació."
|
|||
msgid "Reopen voting period"
|
||||
msgstr "Reobrir el període de votació"
|
||||
|
||||
#: ../views/votes_show_open.erb:9
|
||||
#: ../views/votes_show_open.erb:6
|
||||
msgid "Missing rating for candidate <i>%{name}</i>."
|
||||
msgstr "Falta una valoració per l'opció <i>%{name}</i>."
|
||||
|
||||
#: ../views/votes_show_open.erb:17
|
||||
msgid "Your ratings"
|
||||
msgstr "Les teves valoracions"
|
||||
|
||||
#: ../views/votes_show_open.erb:30
|
||||
#: ../views/votes_show_open.erb:44
|
||||
msgid "Participants"
|
||||
msgstr "Votants"
|
||||
|
||||
#: ../views/votes_show_open.erb:55
|
||||
#: ../views/votes_show_open.erb:69
|
||||
msgid "Change back to draft vote"
|
||||
msgstr "Tornar a l'esborrany de votació"
|
||||
|
||||
#: ../views/votes_show_open.erb:59
|
||||
#: ../views/votes_show_open.erb:73
|
||||
msgid "Close votes and show results"
|
||||
msgstr "Tancar la votació i veure els resultats"
|
||||
|
|
|
|||
32
po/vedia.pot
32
po/vedia.pot
|
|
@ -8,8 +8,8 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2025-06-08 20:44-0600\n"
|
||||
"PO-Revision-Date: 2025-06-08 20:44-0600\n"
|
||||
"POT-Creation-Date: 2025-10-13 20:19+0200\n"
|
||||
"PO-Revision-Date: 2025-10-13 20:19+0200\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
|
|
@ -42,11 +42,11 @@ msgstr ""
|
|||
msgid "Very good"
|
||||
msgstr ""
|
||||
|
||||
#: ../vedia.rb:119
|
||||
#: ../vedia.rb:127
|
||||
msgid "Incorrect email or password."
|
||||
msgstr ""
|
||||
|
||||
#: ../vedia.rb:141
|
||||
#: ../vedia.rb:149
|
||||
msgid "Reset your password"
|
||||
msgstr ""
|
||||
|
||||
|
|
@ -134,7 +134,7 @@ msgid "Description: %{description}"
|
|||
msgstr ""
|
||||
|
||||
#: ../views/admin_votes.erb:15 ../views/votes_open.erb:3
|
||||
#: ../views/votes_show_closed.erb:4 ../views/votes_show_open.erb:4
|
||||
#: ../views/votes_show_closed.erb:4 ../views/votes_show_open.erb:12
|
||||
msgid "Closing date: %{date}"
|
||||
msgstr ""
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ msgstr ""
|
|||
|
||||
#: ../views/admin_votes.erb:19 ../views/votes_edit.erb:39
|
||||
#: ../views/votes_show_closed.erb:79 ../views/votes_show_draft.erb:5
|
||||
#: ../views/votes_show_open.erb:40
|
||||
#: ../views/votes_show_open.erb:54
|
||||
msgid "Organizers"
|
||||
msgstr ""
|
||||
|
||||
|
|
@ -194,7 +194,7 @@ msgstr ""
|
|||
|
||||
#: ../views/login.erb:9 ../views/reset.erb:5 ../views/reset_change.erb:13
|
||||
#: ../views/signup.erb:24 ../views/votes_edit.erb:51
|
||||
#: ../views/votes_show_closed.erb:99 ../views/votes_show_open.erb:66
|
||||
#: ../views/votes_show_closed.erb:99 ../views/votes_show_open.erb:80
|
||||
msgid "Email"
|
||||
msgstr ""
|
||||
|
||||
|
|
@ -267,7 +267,7 @@ msgstr ""
|
|||
msgid "Description"
|
||||
msgstr ""
|
||||
|
||||
#: ../views/votes_edit.erb:12 ../views/votes_show_open.erb:27
|
||||
#: ../views/votes_edit.erb:12 ../views/votes_show_open.erb:41
|
||||
msgid "Save"
|
||||
msgstr ""
|
||||
|
||||
|
|
@ -286,12 +286,12 @@ msgstr ""
|
|||
|
||||
#: ../views/votes_edit.erb:47 ../views/votes_edit.erb:54
|
||||
#: ../views/votes_show_closed.erb:95 ../views/votes_show_closed.erb:102
|
||||
#: ../views/votes_show_open.erb:62 ../views/votes_show_open.erb:69
|
||||
#: ../views/votes_show_open.erb:76 ../views/votes_show_open.erb:83
|
||||
msgid "Add organizer"
|
||||
msgstr ""
|
||||
|
||||
#: ../views/votes_edit.erb:57 ../views/votes_show_closed.erb:89
|
||||
#: ../views/votes_show_open.erb:52
|
||||
#: ../views/votes_show_open.erb:66
|
||||
msgid "Actions for organizers"
|
||||
msgstr ""
|
||||
|
||||
|
|
@ -368,18 +368,22 @@ msgstr ""
|
|||
msgid "Reopen voting period"
|
||||
msgstr ""
|
||||
|
||||
#: ../views/votes_show_open.erb:9
|
||||
#: ../views/votes_show_open.erb:6
|
||||
msgid "Missing rating for candidate <i>%{name}</i>."
|
||||
msgstr ""
|
||||
|
||||
#: ../views/votes_show_open.erb:17
|
||||
msgid "Your ratings"
|
||||
msgstr ""
|
||||
|
||||
#: ../views/votes_show_open.erb:30
|
||||
#: ../views/votes_show_open.erb:44
|
||||
msgid "Participants"
|
||||
msgstr ""
|
||||
|
||||
#: ../views/votes_show_open.erb:55
|
||||
#: ../views/votes_show_open.erb:69
|
||||
msgid "Change back to draft vote"
|
||||
msgstr ""
|
||||
|
||||
#: ../views/votes_show_open.erb:59
|
||||
#: ../views/votes_show_open.erb:73
|
||||
msgid "Close votes and show results"
|
||||
msgstr ""
|
||||
|
|
|
|||
26
vedia.rb
26
vedia.rb
|
|
@ -1,19 +1,22 @@
|
|||
require 'sinatra'
|
||||
|
||||
# Set environment before requiring 'sinatra/activerecord' to make `whenever` uses the database.
|
||||
if ENV['RAILS_ENV']
|
||||
set :environment, ENV['RAILS_ENV']
|
||||
end
|
||||
|
||||
require 'sinatra/activerecord'
|
||||
require 'bcrypt'
|
||||
require 'gettext'
|
||||
require 'securerandom'
|
||||
require 'chartkick'
|
||||
require 'mail'
|
||||
require 'ostruct'
|
||||
require 'tzinfo'
|
||||
require 'redcarpet'
|
||||
|
||||
include GetText
|
||||
|
||||
if ENV['RAILS_ENV']
|
||||
set :environment, ENV['RAILS_ENV']
|
||||
end
|
||||
|
||||
require_relative 'mj'
|
||||
require_relative 'config/environments/defaults.rb'
|
||||
require_relative "config/environments/#{settings.environment}"
|
||||
|
|
@ -384,10 +387,24 @@ post '/votes/:id/reopen' do
|
|||
redirect '/votes/' + @vote.secure_id
|
||||
end
|
||||
|
||||
get '/votes/:id/ratings' do
|
||||
redirect '/votes/' + params[:id]
|
||||
end
|
||||
|
||||
post '/votes/:id/ratings' do
|
||||
require_login
|
||||
find_vote
|
||||
require_open_vote
|
||||
@errors = []
|
||||
@vote.candidates.each do |candidate|
|
||||
if not params[candidate.id.to_s]
|
||||
@errors << OpenStruct.new(:attribute => :rating, :type => :blank, :candidate => candidate)
|
||||
end
|
||||
end
|
||||
if not @errors.empty?
|
||||
@params = params
|
||||
erb :votes_show_open
|
||||
else
|
||||
@vote.candidates.each do |candidate|
|
||||
rating = Rating.find_or_initialize_by(vote: @vote, user: current_user, candidate: candidate)
|
||||
rating.value = params[candidate.id.to_s]
|
||||
|
|
@ -395,6 +412,7 @@ post '/votes/:id/ratings' do
|
|||
end
|
||||
redirect '/votes/' + @vote.secure_id
|
||||
end
|
||||
end
|
||||
|
||||
post '/votes/:id/organizers' do
|
||||
require_login
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
color: red;
|
||||
}
|
||||
|
||||
p, li {
|
||||
max-width: 50em;
|
||||
}
|
||||
|
||||
textarea {
|
||||
width: 80em;
|
||||
height: 20em;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<h1><%= _("Open vote") %></h1>
|
||||
|
||||
<p><%= _("Closing date: %{date}" % { date: format_date_and_time(@expire_on) }) %></p>
|
||||
<p><%= _("Closing date: %{date}") % { date: format_date_and_time(@expire_on) } %></p>
|
||||
|
||||
<p><%= _("The vote will automatically close on that date and the results will
|
||||
be sent to all users by email.") %></p>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<h1><%= @vote.title %></h1>
|
||||
|
||||
<% if @vote.expire_on %>
|
||||
<p><%= _("Closing date: %{date}" % { date: format_date_and_time(@vote.expire_on) }) %></p>
|
||||
<p><%= _("Closing date: %{date}") % { date: format_date_and_time(@vote.expire_on) } %></p>
|
||||
<% end %>
|
||||
|
||||
<%= markdown(@vote.description) %>
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
<% @vote.candidates.each do |candidate| %>
|
||||
<% if rating = @vote.ratings.find { |rating| rating.user == user and rating.candidate == candidate } %>
|
||||
<% value = settings.values.select { |e| e[:id] == rating.value }.first %>
|
||||
<td class="value-<%= value[:id] %>"><%= value[:label] %></td>
|
||||
<td class="value-<%= value[:id] %>"><%= _(value[:label]) %></td>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
|
@ -47,7 +47,7 @@
|
|||
<td><%= i %></td>
|
||||
<td><%= candidate.name %></td>
|
||||
<% value = settings.values.select { |e| e[:id] == candidate.mj.mj }.first %>
|
||||
<td class="value-<%= value[:id] %>"><%= value[:label] %></td>
|
||||
<td class="value-<%= value[:id] %>"><%= _(value[:label]) %></td>
|
||||
<td><%= candidate.mj.proponents %></td>
|
||||
<td><%= candidate.mj.opponents %></td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,15 @@
|
|||
<h1><%= @vote.title %></h1>
|
||||
|
||||
<% if @errors %>
|
||||
<% @errors.each do |error| %>
|
||||
<% if error.attribute == :rating and error.type == :blank %>
|
||||
<p class="error"><%= _("Missing rating for candidate <i>%{name}</i>.") % { name: error.candidate.name } %></p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if @vote.expire_on %>
|
||||
<p><%= _("Closing date: %{date}" % { date: format_date_and_time(@vote.expire_on) }) %></p>
|
||||
<p><%= _("Closing date: %{date}") % { date: format_date_and_time(@vote.expire_on) } %></p>
|
||||
<% end %>
|
||||
|
||||
<%= markdown(@vote.description) %>
|
||||
|
|
@ -12,13 +20,19 @@
|
|||
<ul>
|
||||
<% @vote.candidates.each do |candidate| %>
|
||||
<% rating = @vote.ratings.find { |rating| rating.user == current_user and rating.candidate == candidate } %>
|
||||
<% value = rating ? rating.value : 0 %>
|
||||
<% if rating
|
||||
value = rating.value
|
||||
elsif @params[candidate.id.to_s]
|
||||
value = params[candidate.id.to_s].to_i
|
||||
else
|
||||
value = 0
|
||||
end %>
|
||||
<li>
|
||||
<p><b><%= candidate.name %></b></p>
|
||||
<%= markdown(candidate.description) %>
|
||||
<ul>
|
||||
<% settings.values.reverse.each do |v| %>
|
||||
<li><input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-<%= v[:id] %>" value="<%= v[:id] %>" <% if value == v[:id] %>checked<% end %>><label for="<%= candidate.id %>-<%= v[:id] %>" class="value-<%= v[:id] %>"><%= v[:label] %></label></li>
|
||||
<li><input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-<%= v[:id] %>" value="<%= v[:id] %>" <% if value == v[:id] %>checked<% end %>><label for="<%= candidate.id %>-<%= v[:id] %>" class="value-<%= v[:id] %>"><%= _(v[:label]) %></label></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</li>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue