hide fields from the file form if not matching the file's role

This commit is contained in:
Hauke Klement
2015-03-12 17:04:47 +01:00
parent a62d4ad789
commit cd09e19d24
3 changed files with 23 additions and 10 deletions

View File

@ -9,8 +9,9 @@ module CodeOcean
TEACHER_DEFINED_ROLES = ROLES - %w(user_defined_file)
after_initialize :set_default_values
before_validation :set_ancestor_values, if: :incomplete_descendent?
before_validation :clear_weight, unless: :teacher_defined_test?
before_validation :hash_content, if: :content_present?
before_validation :set_ancestor_values, if: :incomplete_descendent?
belongs_to :context, polymorphic: true
belongs_to :execution_environment
@ -49,6 +50,11 @@ module CodeOcean
file_id || id
end
def clear_weight
self.weight = nil
end
private :clear_weight
def content_present?
content? || native_file?
end