Modified: trunk/lib/rest.rb (2317 => 2318)
--- trunk/lib/rest.rb 2010-01-18 13:59:35 UTC (rev 2317)
+++ trunk/lib/rest.rb 2010-01-20 13:44:13 UTC (rev 2318)
@@ -1638,54 +1638,55 @@
# Start of curation hack
- if user && subject && Conf.curators.include?(user.username)
+ if comment[0..1].downcase == 'c:' && user && subject &&
+ Conf.curators.include?(user.username)
+ comment = comment[2..-1].strip
+
lines = comment.split("\n")
events = []
failed = false
- if lines[0] && lines[0].downcase == 'c:'
- lines[1..-1].each do |line|
+ lines.each do |line|
- line.strip!
+ line.strip!
- bits = line.split(" - ")
+ bits = line.split(" - ")
- if bits.length > 1
- details = bits[1..-1].join(" - ")
- else
- details = nil
- end
+ if bits.length > 1
+ details = bits[1..-1].join(" - ")
+ else
+ details = nil
+ end
- if bits.length > 0
- bits[0].split(",").each do |bit|
+ if bits.length > 0
+ bits[0].split(",").each do |bit|
- bit.downcase!
- bit.strip!
+ bit.downcase!
+ bit.strip!
- if Conf.curation_types.include?(bit)
- events.push(CurationEvent.new(:category => bit,
- :object => subject, :user => user, :details => details))
- else
- failed = true
- end
+ if Conf.curation_types.include?(bit)
+ events.push(CurationEvent.new(:category => bit,
+ :object => subject, :user => user, :details => details))
+ else
+ failed = true
end
end
end
+ end
- if failed
- return rest_response(400, :reason => 'Unrecognised curation term')
- end
+ if failed
+ return rest_response(400, :reason => 'Unrecognised curation term')
+ end
- events.each do |event|
- event.save
- end
+ events.each do |event|
+ event.save
+ end
- subject.solr_save
+ subject.solr_save
- return rest_get_request(ob, "comment", user, rest_resource_uri(ob),
- "comment", { "id" => ob.id.to_s })
- end
+ return rest_get_request(ob, "comment", user, rest_resource_uri(ob),
+ "comment", { "id" => ob.id.to_s })
end
# End of curation hack