Compare commits
No commits in common. "0e291dc31c08d8560f0861d7a20c081553394b6a" and "495d29a0aebd21a204d3213b17b26a51a0a16eaa" have entirely different histories.
0e291dc31c
...
495d29a0ae
5 changed files with 12 additions and 73 deletions
1
Gemfile
1
Gemfile
|
|
@ -12,4 +12,3 @@ gem 'bcrypt'
|
||||||
gem 'gettext'
|
gem 'gettext'
|
||||||
gem 'mail'
|
gem 'mail'
|
||||||
gem 'redcarpet'
|
gem 'redcarpet'
|
||||||
gem 'whenever'
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ GEM
|
||||||
bcrypt (3.1.20)
|
bcrypt (3.1.20)
|
||||||
benchmark (0.4.0)
|
benchmark (0.4.0)
|
||||||
bigdecimal (3.1.9)
|
bigdecimal (3.1.9)
|
||||||
chronic (0.10.2)
|
|
||||||
concurrent-ruby (1.3.5)
|
concurrent-ruby (1.3.5)
|
||||||
connection_pool (2.5.0)
|
connection_pool (2.5.0)
|
||||||
date (3.4.1)
|
date (3.4.1)
|
||||||
|
|
@ -93,16 +92,11 @@ GEM
|
||||||
singleton (0.3.0)
|
singleton (0.3.0)
|
||||||
sqlite3 (2.6.0)
|
sqlite3 (2.6.0)
|
||||||
mini_portile2 (~> 2.8.0)
|
mini_portile2 (~> 2.8.0)
|
||||||
sqlite3 (2.6.0-arm64-darwin)
|
|
||||||
sqlite3 (2.6.0-x86_64-darwin)
|
|
||||||
sqlite3 (2.6.0-x86_64-linux-gnu)
|
|
||||||
text (1.3.1)
|
text (1.3.1)
|
||||||
tilt (2.6.0)
|
tilt (2.6.0)
|
||||||
timeout (0.4.3)
|
timeout (0.4.3)
|
||||||
tzinfo (2.0.6)
|
tzinfo (2.0.6)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
whenever (1.1.2)
|
|
||||||
chronic (>= 0.6.3)
|
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
arm64-darwin
|
arm64-darwin
|
||||||
|
|
@ -123,7 +117,6 @@ DEPENDENCIES
|
||||||
sinatra
|
sinatra
|
||||||
sinatra-activerecord
|
sinatra-activerecord
|
||||||
sqlite3
|
sqlite3
|
||||||
whenever
|
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
2.3.15
|
2.3.15
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
require_relative '../vedia'
|
if ENV['RACK_ENV']
|
||||||
|
set :environment, ENV['RACK_ENV']
|
||||||
env 'MAILTO', Sinatra::Application.settings.admin
|
end
|
||||||
set :path, Sinatra::Application.settings.path
|
|
||||||
set :environment_variable, 'RACK_ENV'
|
|
||||||
|
|
||||||
every 5.minutes do
|
every 5.minutes do
|
||||||
rake "close_expired_votes"
|
rake "close_expired_votes"
|
||||||
|
|
|
||||||
29
vedia.rb
29
vedia.rb
|
|
@ -1,4 +1,10 @@
|
||||||
require 'sinatra'
|
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 'sinatra/activerecord'
|
||||||
require 'bcrypt'
|
require 'bcrypt'
|
||||||
require 'gettext'
|
require 'gettext'
|
||||||
|
|
@ -260,22 +266,7 @@ get '/admin/votes/:id' do
|
||||||
erb :admin_votes
|
erb :admin_votes
|
||||||
end
|
end
|
||||||
|
|
||||||
post '/admin/votes/:id' do
|
get '/admin/votes/:id/organizers/:user/delete' do
|
||||||
require_admin
|
|
||||||
@vote = Vote.find(params[:id])
|
|
||||||
if params.has_key?('year')
|
|
||||||
new_expiry = TZInfo::Timezone.get(session[:timezone]).local_time(params['year'].to_i, params['month'].to_i, params['day'].to_i, params['hour'].to_i, params['minute'].to_i)
|
|
||||||
if (@vote.state == 'open' or @vote.state == 'closed') and new_expiry > Time.now
|
|
||||||
puts "change"
|
|
||||||
@vote.expire_on = new_expiry
|
|
||||||
@vote.state = 'open'
|
|
||||||
@vote.save
|
|
||||||
end
|
|
||||||
end
|
|
||||||
erb :admin_votes
|
|
||||||
end
|
|
||||||
|
|
||||||
get 'admin/votes/:id/organizers/:user/delete' do
|
|
||||||
require_admin
|
require_admin
|
||||||
rating = Organizer.where(vote: params[:id]).where(user: params[:user]).each do |organizer|
|
rating = Organizer.where(vote: params[:id]).where(user: params[:user]).each do |organizer|
|
||||||
organizer.destroy
|
organizer.destroy
|
||||||
|
|
@ -659,12 +650,8 @@ helpers do
|
||||||
"#{TZInfo::Timezone.get(session[:timezone]).to_local(timestamp).strftime('%F')}"
|
"#{TZInfo::Timezone.get(session[:timezone]).to_local(timestamp).strftime('%F')}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_timezone
|
|
||||||
session[:timezone].gsub('_', ' ')
|
|
||||||
end
|
|
||||||
|
|
||||||
def format_date_and_time(timestamp)
|
def format_date_and_time(timestamp)
|
||||||
"#{TZInfo::Timezone.get(session[:timezone]).to_local(timestamp).strftime('%F %R')} (#{format_timezone})"
|
"#{TZInfo::Timezone.get(session[:timezone]).to_local(timestamp).strftime('%F %R')} (#{session[:timezone].gsub('_', ' ')})"
|
||||||
end
|
end
|
||||||
|
|
||||||
def markdown(markdown)
|
def markdown(markdown)
|
||||||
|
|
|
||||||
|
|
@ -12,45 +12,7 @@
|
||||||
|
|
||||||
<p><%= _("Description: %{description}") % { description: @vote.description } %></p>
|
<p><%= _("Description: %{description}") % { description: @vote.description } %></p>
|
||||||
|
|
||||||
<% if @vote.state == 'closed' or @vote.state == 'open' %>
|
<p><%= _("Closing date: %{date}") % { date: @vote.expire_on ? format_date_and_time(@vote.expire_on) : _("None") } %></p>
|
||||||
<form action="/admin/votes/<%= @vote.id %>" method="post">
|
|
||||||
<p>
|
|
||||||
<%= _("Closing date: ") %>
|
|
||||||
<% year = Time.now.strftime('%Y').to_i %>
|
|
||||||
<select name='year'>
|
|
||||||
<% (-1..1).each do |i| %>
|
|
||||||
<option value="<%= year + i %>"<% if TZInfo::Timezone.get(session[:timezone]).to_local(@vote.expire_on).strftime('%Y').to_i == year + i %> selected="selected"<% end %>><%= year + i %></option>
|
|
||||||
<% end %>
|
|
||||||
</select>
|
|
||||||
-
|
|
||||||
<select name='month'>
|
|
||||||
<% (1..11).each do |m| %>
|
|
||||||
<option value="<%= m %>"<% if TZInfo::Timezone.get(session[:timezone]).to_local(@vote.expire_on).strftime('%m').to_i == m %> selected="selected"<% end %>><%= m %></option>
|
|
||||||
<% end %>
|
|
||||||
</select>
|
|
||||||
-
|
|
||||||
<select name='day'>
|
|
||||||
<% (1..31).each do |d| %>
|
|
||||||
<option value="<%= d %>"<% if TZInfo::Timezone.get(session[:timezone]).to_local(@vote.expire_on).strftime('%d').to_i == d %> selected="selected"<% end %>><%= d %></option>
|
|
||||||
<% end %>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select name='hour'>
|
|
||||||
<% (0..23).each do |h| %>
|
|
||||||
<option value="<%= h %>"<% if TZInfo::Timezone.get(session[:timezone]).to_local(@vote.expire_on).strftime('%H').to_i == h %> selected="selected"<% end %>><%= h %></option>
|
|
||||||
<% end %>
|
|
||||||
</select>
|
|
||||||
:
|
|
||||||
<select name='minute'>
|
|
||||||
<% (0..59).each do |m| %>
|
|
||||||
<option value="<%= m %>"<% if TZInfo::Timezone.get(session[:timezone]).to_local(@vote.expire_on).strftime('%M').to_i == m %> selected="selected"<% end %>><%= m %></option>
|
|
||||||
<% end %>
|
|
||||||
</select>
|
|
||||||
(<%= format_timezone %>)
|
|
||||||
<button type="submit" class="btn btn-link"><%= _("Change") %></button>
|
|
||||||
</p>
|
|
||||||
</form>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<p class="mb-5"><%= _("State: %{state}") % { state: @vote.state } %></p>
|
<p class="mb-5"><%= _("State: %{state}") % { state: @vote.state } %></p>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue