removed url helper from model
This commit is contained in:
@ -28,17 +28,6 @@ class Submission < ActiveRecord::Base
|
||||
ancestors.merge(descendants).values
|
||||
end
|
||||
|
||||
[:download_file, :render, :run, :test].each do |action|
|
||||
filename = FILENAME_URL_PLACEHOLDER.gsub(/\W/, '')
|
||||
define_method("#{action}_url") do
|
||||
Rails.application.routes.url_helpers.send(:"#{action}_submission_path", self, filename).sub(filename, FILENAME_URL_PLACEHOLDER)
|
||||
end
|
||||
end
|
||||
|
||||
def download_url
|
||||
Rails.application.routes.url_helpers.send(:download_submission_path, self)
|
||||
end
|
||||
|
||||
def main_file
|
||||
collect_files.detect(&:main_file?)
|
||||
end
|
||||
@ -56,12 +45,6 @@ class Submission < ActiveRecord::Base
|
||||
(normalized_score * 100).round
|
||||
end
|
||||
|
||||
[:score, :stop].each do |action|
|
||||
define_method("#{action}_url") do
|
||||
Rails.application.routes.url_helpers.send(:"#{action}_submission_path", self)
|
||||
end
|
||||
end
|
||||
|
||||
def siblings
|
||||
user.submissions.where(exercise_id: exercise_id)
|
||||
end
|
||||
|
@ -1 +1,8 @@
|
||||
json.extract! @submission, :download_url, :download_file_url, :id, :score_url, :render_url, :run_url, :stop_url, :test_url, :files
|
||||
json.extract! @submission, :id, :files
|
||||
json.download_url download_submission_path(@submission)
|
||||
json.score_url score_submission_path(@submission)
|
||||
json.stop_url stop_submission_path(@submission)
|
||||
json.download_file_url download_file_submission_path(@submission, 'a.').gsub(/a\.$/, '{filename}')
|
||||
json.render_url render_submission_path(@submission, 'a.').gsub(/a\.$/, '{filename}')
|
||||
json.run_url run_submission_path(@submission, 'a.').gsub(/a\.$/, '{filename}')
|
||||
json.test_url test_submission_path(@submission, 'a.').gsub(/a\.$/, '{filename}')
|
||||
|
Reference in New Issue
Block a user