Minor fixes needed for last_timeline to work.

* Added route back for PUT /ts_api/user/<username>
* Fixed typo in ``ts_api:put_user/2``.
* Fixed incorrect expected return from ``ts_ext_data:set_property/3``.
* Added missing assignment for ``ts_user.email`` in the appropriate
  ``ts_json:construct_record/3`` clause.
* Fixed model attribute assignment in ``ts.js``.
This commit is contained in:
Jonathan Bernard 2011-06-15 18:31:53 -05:00
parent cd182d54c3
commit 602bdca7e3
7 changed files with 7 additions and 5 deletions

Binary file not shown.

Binary file not shown.

View File

@ -84,6 +84,7 @@ dispatch_user(YArg, Session, [Username]) ->
case {HTTPMethod, Session#ts_api_session.username} of case {HTTPMethod, Session#ts_api_session.username} of
{'GET', Username} -> get_user(YArg, Username); {'GET', Username} -> get_user(YArg, Username);
{'PUT', Username} -> put_user(YArg, Username);
{_BadMethod, Username} -> {_BadMethod, Username} ->
make_json_405(YArg, [{see_docs, "/ts_api_doc/users.html"}]); make_json_405(YArg, [{see_docs, "/ts_api_doc/users.html"}]);
@ -253,7 +254,7 @@ put_user(YArg, Username) ->
EJSON = parse_json_body(YArg), EJSON = parse_json_body(YArg),
{UR, ExtData} = {UR, ExtData} =
try ts_user:ejson_to_record_strict(#ts_user{username=Username}, EJSON) try ts_json:ejson_to_record_strict(#ts_user{username=Username}, EJSON)
catch throw:{InputError, StackTrace} -> catch throw:{InputError, StackTrace} ->
error_logger:error_report("Bad input in put_user/2: ~p", error_logger:error_report("Bad input in put_user/2: ~p",
[InputError]), [InputError]),

View File

@ -102,7 +102,7 @@ list(Query, Start, Length) ->
do_set_ext_data(Record, ExtData) when is_list(ExtData) -> do_set_ext_data(Record, ExtData) when is_list(ExtData) ->
lists:foreach( lists:foreach(
fun({Key, Val}) -> fun({Key, Val}) ->
{atomic, ok} = ts_ext_data:set_property(Record, Key, Val) ok = ts_ext_data:set_property(Record, Key, Val)
end, end,
ExtData), ExtData),
ok. ok.

View File

@ -44,7 +44,7 @@ get_properties(Rec) ->
{Key, ExtData#ts_ext_data.value} end, Result). {Key, ExtData#ts_ext_data.value} end, Result).
do_set_property(Ref, PropKey, Val) -> do_set_property(Ref, PropKey, Val) ->
{atomic, Result} = mnesia:transaction(fun() -> {atomic, _Result} = mnesia:transaction(fun() ->
mnesia:write(#ts_ext_data{ref = {Ref, PropKey}, value = Val}) mnesia:write(#ts_ext_data{ref = {Ref, PropKey}, value = Val})
end), end),
Result. ok.

View File

@ -122,6 +122,7 @@ construct_record(User=#ts_user{}, [{Key, Value}|Fields], ExtData) ->
id -> construct_record(User#ts_user{username = Value}, id -> construct_record(User#ts_user{username = Value},
Fields, ExtData); Fields, ExtData);
name -> construct_record(User#ts_user{name = Value}, Fields, ExtData); name -> construct_record(User#ts_user{name = Value}, Fields, ExtData);
email -> construct_record(User#ts_user{email = Value}, Fields, ExtData);
join_date -> construct_record( join_date -> construct_record(
User#ts_user{join_date = decode_datetime(Value)}, User#ts_user{join_date = decode_datetime(Value)},
Fields, ExtData); Fields, ExtData);

View File

@ -559,7 +559,7 @@ $(document).ready(function(){
this.entries.collection.timeline = tl; this.entries.collection.timeline = tl;
// update the last_timeline field of the user model // update the last_timeline field of the user model
this.user.model.set('last_timeline', tl.get('id'); this.user.model.set({last_timeline: tl.get('id')});
this.user.model.save(); this.user.model.save();
// refresh TimelineListView // refresh TimelineListView