Fix a few pages in views

This commit is contained in:
Ari Timonen 2020-04-01 05:40:17 +03:00
parent ce5dfcfa6a
commit b0c9697109
6 changed files with 27 additions and 17 deletions

View file

@ -90,7 +90,10 @@ module ApplicationHelper
end
end
# Print the attributes from the list
def cascade model, list
return "" if model.nil?
out = list.map do |element|
name = key = element
item = ""
@ -104,10 +107,15 @@ module ApplicationHelper
if m = key.to_s.match(/^(.*)_b$/)
name = m[1]
key = m[1]
end
begin
str = eval("model.#{key}")
rescue
next
end
str = eval("model.#{key}")
next if str == "" or str.nil?
next if str == "" or str.nil?
if model[key].instance_of?(Time) or model[key].instance_of?(ActiveSupport::TimeWithZone)
# result << shorttime(str)

View file

@ -89,11 +89,11 @@ class Article < ActiveRecord::Base
end
def previous_article
category.articles.nodrafts.first&.(where("id < ?", self.id).order("id DESC"))
category.articles.nodrafts.where("id < ?", self.id).order("id DESC").first
end
def next_article
category.articles.nodrafts.first&.(where("id > ?", self.id).order("id ASC"))
category.articles.nodrafts.where("id > ?", self.id).order("id ASC").first
end
def statuses

View file

@ -58,7 +58,7 @@ class Directory < ActiveRecord::Base
validates_with PathValidator
# TODO: add validation for path
before_validation :init_variables, on: :create
before_validation :init_variables
after_create :make_path
after_save :update_timestamp
before_destroy :remove_files, unless: Proc.new { preserve_files }

View file

@ -1,6 +1,6 @@
<h1>General Information</h1>
<p>
We are a free-working organization founded in 2005 which has organized various competitions for the Half-Life mod Natural Selection.
We are a non-profit organization founded in 2005 which has organized various competitions for the Half-Life mod Natural Selection.
We now primarily focus on its successor, Natural Selection 2.
</p>
<p>To contact us:</p>
@ -8,7 +8,7 @@
<ol>
<li>Use the <%= link_to 'contact', new_issue_path %> form</li>
<li>Join our official <%= link_to 'discord', 'https://discord.gg/Bvs3KjX' %></li>
<li>Send email to the head admin as per the list below (mind that some email adresses are not shown due to privacy settings)</li>
<li>Send email to the head admin from list below (some email adresses are not shown due to privacy settings)</li>
<li>Contact other staff members directly, check below and click profile for contact details</li>
</ol>
</p>

View file

@ -83,7 +83,7 @@
<% if cuser and cuser.admin? %>
<div class="controls">
<%= link_to "Edit Directory", edit_directory_path(dir), class: 'button' %>
<%= link_to "Delete Directory", dir, data: { confirm: "Are you sure?" }, class: 'button' %>
<%= link_to "Delete Directory", dir, data: { confirm: "Are you sure?" }, method: 'delete', class: 'button' %>
<%= link_to "New Directory", { controller: "directories", action: "new", id: dir }, { class: 'button' } %>
<%= link_to "New File", { controller: "data_files", action: "new", id: dir }, { class: 'button' } %>
</div>

View file

@ -11,15 +11,17 @@
<%= cascade movie, ["content", "format", ["Author", :user], "length_s", ["Views", "view_count"], ["Date", "file.created_at"]] %>
<% (params[:action] == "show" ? movie.all_files : [movie.file]).each do |file| %>
<b>File: </b> <%= link_to File.basename(file.name.to_s), file.url %>
<ul>
<li>
<strong>MD5:</strong> <%= file.md5_s %>
</li>
<li>
<strong>Size:</strong> <%= file.size_s %> MB
</li>
</ul>
<% unless file.nil? %>
<b>File: </b> <%= link_to File.basename(file.name.to_s), file.url %>
<ul>
<li>
<strong>MD5:</strong> <%= file.md5_s %>
</li>
<li>
<strong>Size:</strong> <%= file.size_s %> MB
</li>
</ul>
<% end %>
<% end %>
<% if cuser and movie.can_update? cuser %>