webmcp
annotate demo-app/app/main/medium/_action/update.lua @ 11:d76a8857ba62
Added ui.partial and other functions, which allow partial content replacement using XMLHttpRequests; Image support for ui.link
Also includes following changes:
- Fix for rocketcgi library to accept POST data content-types, which contain additional charset information.
- Support arrays passed as params to encode.url (only for keys ending with "[]")
- Version information changed to "1.0.7"
Documentation for added functions is not yet complete.
Also includes following changes:
- Fix for rocketcgi library to accept POST data content-types, which contain additional charset information.
- Support arrays passed as params to encode.url (only for keys ending with "[]")
- Version information changed to "1.0.7"
Documentation for added functions is not yet complete.
| author | jbe/bsw | 
|---|---|
| date | Fri Feb 12 18:40:22 2010 +0100 (2010-02-12) | 
| parents | 9fdfb27f8e67 | 
| children | 
| rev | line source | 
|---|---|
| jbe/bsw@0 | 1 local medium | 
| jbe/bsw@0 | 2 local id = param.get_id() | 
| jbe/bsw@0 | 3 if id then | 
| jbe/bsw@0 | 4 medium = Medium:by_id(id) | 
| jbe/bsw@0 | 5 else | 
| jbe/bsw@0 | 6 medium = Medium:new() | 
| jbe/bsw@0 | 7 end | 
| jbe/bsw@0 | 8 | 
| jbe/bsw@0 | 9 if param.get("delete", atom.boolean) then | 
| jbe/bsw@0 | 10 local name = medium.name | 
| jbe/bsw@0 | 11 medium:destroy() | 
| jbe/bsw@0 | 12 slot.put_into("notice", _("Medium '#{name}' deleted", {name = name})) | 
| jbe/bsw@0 | 13 return | 
| jbe/bsw@0 | 14 end | 
| jbe/bsw@0 | 15 | 
| jbe/bsw@0 | 16 param.update(medium, "media_type_id", "name", "copyprotected") | 
| jbe/bsw@0 | 17 | 
| jbe/bsw@0 | 18 medium:save() | 
| jbe/bsw@0 | 19 | 
| jbe/bsw@0 | 20 param.update_relationship{ | 
| jbe/bsw@0 | 21 param_name = "genres", | 
| jbe/bsw@0 | 22 id = medium.id, | 
| jbe/bsw@0 | 23 connecting_model = Classification, | 
| jbe/bsw@0 | 24 own_reference = "medium_id", | 
| jbe/bsw@0 | 25 foreign_reference = "genre_id" | 
| jbe/bsw@0 | 26 } | 
| jbe/bsw@0 | 27 | 
| jbe/bsw@0 | 28 for index, prefix in param.iterate("tracks") do | 
| jbe/bsw@0 | 29 local id = param.get(prefix .. "id", atom.integer) | 
| jbe/bsw@0 | 30 local track | 
| jbe/bsw@0 | 31 if id then | 
| jbe/bsw@0 | 32 track = Track:by_id(id) | 
| jbe/bsw@0 | 33 elseif #param.get(prefix .. "name") > 0 then | 
| jbe/bsw@0 | 34 track = Track:new() | 
| jbe/bsw@0 | 35 track.medium_id = medium.id | 
| jbe/bsw@0 | 36 else | 
| jbe/bsw@0 | 37 break | 
| jbe/bsw@0 | 38 end | 
| jbe/bsw@0 | 39 track.position = param.get(prefix .. "position", atom.integer) | 
| jbe/bsw@0 | 40 track.name = param.get(prefix .. "name") | 
| jbe/bsw@0 | 41 track.description = param.get(prefix .. "description") | 
| jbe/bsw@0 | 42 track.duration = param.get(prefix .. "duration") | 
| jbe/bsw@0 | 43 track:save() | 
| jbe/bsw@0 | 44 end | 
| jbe/bsw@0 | 45 | 
| jbe/bsw@0 | 46 | 
| jbe/bsw@0 | 47 if id then | 
| jbe/bsw@0 | 48 slot.put_into("notice", _("Medium '#{name}' updated", {name = medium.name})) | 
| jbe/bsw@0 | 49 else | 
| jbe/bsw@0 | 50 slot.put_into("notice", _("Medium '#{name}' created", {name = medium.name})) | 
| jbe/bsw@0 | 51 end |