[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[myexperiment-hackers] [3130] trunk/app/models/pack.rb: Fixes to resolve
From: |
Danius Michaelides |
Subject: |
[myexperiment-hackers] [3130] trunk/app/models/pack.rb: Fixes to resolve_link for adding: (fwd) |
Date: |
Wed, 19 Sep 2012 18:10:17 +0100 (BST) |
User-agent: |
Alpine 2.00 (LRH 1167 2008-08-23) |
Doh, that should read:
- fix failing to find file (one mapping too many)
Danius
---------- Forwarded message ----------
Date: Wed, 19 Sep 2012 18:08:13
From: address@hidden
Reply-To: address@hidden
To: address@hidden
Subject: [myexperiment-hackers] [3130] trunk/app/models/pack.rb: Fixes to
resolve_link for adding:
Revision
3130
Author
dtm
Date
2012-09-19 17:08:12 +0000 (Wed, 19 Sep 2012)
Log Message
Fixes to resolve_link for adding:
- fix failing to find packs (one mapping too many)
- catch something went wrong exception with when using
ActionController::Routing::Routes.recognize_path
- let non-contributables be added as external links
Modified Paths
* trunk/app/models/pack.rb
Diff
Modified: trunk/app/models/pack.rb (3129 => 3130)
--- trunk/app/models/pack.rb 2012-09-19 09:58:31 UTC (rev 3129)
+++ trunk/app/models/pack.rb 2012-09-19 17:08:12 UTC (rev 3130)
@@ -513,9 +513,12 @@
contributable = nil
# Use Rails' routing to figure out the URL
- request = ActionController::Routing::Routes.recognize_path(uri.path
, :method => :get)
- model_name = request[:controller].classify
- model_name = Conf.model_aliases.index(model_name) || model_name # G
et proper name for model i.e. File -> Blob
+ begin
+ request = ActionController::Routing::Routes.recognize_path(uri.pa
th, :method => :get)
+ model_name = request[:controller].classify
+ rescue Exception => exc
+ raise URI::InvalidURIError
+ end
if Conf.contributable_models.include?(model_name) && request[:actio
n] == "show"
contributable = eval(model_name).find_by_id(request[:id])
@@ -523,27 +526,29 @@
is_remote = true # Treat as a remote entry
end
- if contributable && errors_here.empty?
- entry = PackContributableEntry.new
- entry.contributable = contributable
-
- type = 'contributable'
-
- # check if the 'contributable' is a pack, then that it's not the
same pack,
- # to which we are trying to add something at the moment
- if contributable == self.id
- errors_here.add_to_base('Cannot add the pack to itself')
+ if !is_remote
+ if contributable && errors_here.empty?
+ entry = PackContributableEntry.new
+ entry.contributable = contributable
+
+ type = 'contributable'
+
+ # check if the 'contributable' is a pack, then that it's not th
e same pack,
+ # to which we are trying to add something at the moment
+ if contributable == self.id
+ errors_here.add_to_base('Cannot add the pack to itself')
+ end
+
+ # Check if version was specified in the uri
+ entry.contributable_version = request[:version]
+
+ # maybe it was as a query instead?
+ if uri.query
+ entry.contributable_version = CGI.parse(uri.query)["version"]
.first.try(:to_i)
+ end
+ else
+ errors_here.add_to_base('The item the link points to does not e
xist.')
end
-
- # Check if version was specified in the uri
- entry.contributable_version = request[:version]
-
- # maybe it was as a query instead?
- if uri.query
- entry.contributable_version = CGI.parse(uri.query)["version"].f
irst.try(:to_i)
- end
- else
- errors_here.add_to_base('The item the link points to does not exi
st.')
end
else
is_remote = true # Treat as a remote entry
_______________________________________________
myexperiment-hackers mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/myexperiment-hackers
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [myexperiment-hackers] [3130] trunk/app/models/pack.rb: Fixes to resolve_link for adding: (fwd),
Danius Michaelides <=