Commit daea8e3e9b8dda33ea358b0bbf329a6ef3f739fe
Exists in
master
and in
28 other branches
Merge branch 'ai3145' into 'stable'
Fix duplicate author folder creation and duplicate save of work assignments http://noosfero.org/Development/ActionItem3145
Showing
2 changed files
with
2 additions
and
4 deletions
Show diff stats
plugins/work_assignment/lib/ext/uploaded_file.rb
... | ... | @@ -2,13 +2,11 @@ require_dependency 'article' |
2 | 2 | require_dependency 'uploaded_file' |
3 | 3 | |
4 | 4 | class UploadedFile < Article |
5 | - after_save do |uploaded_file| | |
5 | + before_validation do |uploaded_file| | |
6 | 6 | if uploaded_file.parent.kind_of?(WorkAssignmentPlugin::WorkAssignment) |
7 | 7 | author_folder = uploaded_file.parent.find_or_create_author_folder(uploaded_file.author) |
8 | 8 | uploaded_file.name = WorkAssignmentPlugin::WorkAssignment.versioned_name(uploaded_file, author_folder) |
9 | 9 | uploaded_file.parent = author_folder |
10 | - logger.info("\n\n==> #{uploaded_file.name}\n\n") | |
11 | - uploaded_file.save! | |
12 | 10 | end |
13 | 11 | end |
14 | 12 | end | ... | ... |
plugins/work_assignment/lib/work_assignment_plugin/work_assignment.rb
... | ... | @@ -33,7 +33,7 @@ class WorkAssignmentPlugin::WorkAssignment < Folder |
33 | 33 | end |
34 | 34 | |
35 | 35 | def find_or_create_author_folder(author) |
36 | - children.find_by_slug(author.identifier.to_slug) || Folder.create!(:name => author.name, :slug => author.identifier.to_slug, :parent => self, :profile => profile) | |
36 | + children.find_by_slug(author.identifier) || Folder.create!(:name => author.name, :slug => author.identifier, :parent => self, :profile => profile) | |
37 | 37 | end |
38 | 38 | |
39 | 39 | def submissions | ... | ... |