mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
rearrange helper functions
This commit is contained in:
parent
f63259f187
commit
5b1a730e19
5 changed files with 30 additions and 71 deletions
|
|
@ -1,5 +1,4 @@
|
|||
module ApplicationHelper
|
||||
##
|
||||
# Returns a string build from the start and end date of the given conference.
|
||||
#
|
||||
# If the conference is only one day long
|
||||
|
|
@ -34,23 +33,6 @@ module ApplicationHelper
|
|||
result
|
||||
end
|
||||
|
||||
# Returns time with conference timezone
|
||||
def time_with_timezone(time)
|
||||
time.strftime('%F %R') + ' ' + @conference.timezone.to_s
|
||||
end
|
||||
|
||||
##
|
||||
# Checks if the voting has already started, or if it has already ended
|
||||
#
|
||||
def voting_open_or_close(program)
|
||||
return if program.voting_period?
|
||||
if program.voting_start_date > Time.current
|
||||
return 'Voting period has not started yet!'
|
||||
else # voting_end_date > Date.today because voting_start_date < voting_end_date
|
||||
return 'Voting period is over!'
|
||||
end
|
||||
end
|
||||
|
||||
# Set resource_name for devise so that we can call the devise help links (views/devise/shared/_links) from anywhere (eg sign_up form in proposals#new)
|
||||
def resource_name
|
||||
:user
|
||||
|
|
@ -130,9 +112,21 @@ module ApplicationHelper
|
|||
object
|
||||
end
|
||||
|
||||
def quantity_left_of(resource)
|
||||
return '-/-' if resource.quantity.blank?
|
||||
"#{resource.quantity - resource.used}/#{resource.quantity}"
|
||||
def normalize_array_length(hashmap, length)
|
||||
hashmap.each do |_, value|
|
||||
if value.length < length
|
||||
value.fill(value[-1], value.length...length)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Same as redirect_to(:back) if there is a valid HTTP referer, otherwise redirect_to()
|
||||
def redirect_back_or_to(options = {}, response_status = {})
|
||||
if request.env['HTTP_REFERER']
|
||||
redirect_to :back
|
||||
else
|
||||
redirect_to options, response_status
|
||||
end
|
||||
end
|
||||
|
||||
def concurrent_events(event)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue