Skip to content
This repository was archived by the owner on Apr 17, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
03bae0d
Moderators can now move comment threads between posts.
LucasSloan Jul 23, 2013
a95fa1a
Children of original movers now hidden for non-admins.
LucasSloan Jul 23, 2013
c7fc246
Made it impossible to vote on moved items.
LucasSloan Jul 23, 2013
2739bef
Status message removed in the event of failed call.
LucasSloan Jul 23, 2013
eefd50e
Entering an properly formatted URL that doesn't lead to a post sends …
LucasSloan Jul 23, 2013
f3721e5
Changed movebox doc string, renamed Link._byURL to Link._move_url.
LucasSloan Jul 24, 2013
afe23b1
Added a lock to movement.
LucasSloan Jul 24, 2013
582d9fd
Changed move proceedure to no longer create new comments. All calls …
LucasSloan Jul 27, 2013
ac9ed72
Removed debugging statements, moved boolean.
LucasSloan Jul 27, 2013
fa13a33
Safed movement against editor trying to move children of already move…
LucasSloan Jul 27, 2013
b7e7355
Merge branch 'interesting_comments' of https://github.com/PotatoDumpl…
LucasSloan Sep 21, 2013
91d0c4e
Descendant karma attribute no longer disappears off python objects.
LucasSloan Oct 1, 2013
bedd944
Merge branch 'interesting_comments' of https://github.com/PotatoDumpl…
LucasSloan Oct 1, 2013
cf10a31
Thread movement now properly increments descendant karma.
LucasSloan Oct 1, 2013
2edef55
Descendant karma attribute no longer disappears off python objects.
LucasSloan Oct 1, 2013
33a3850
Merge branch 'interesting_comments' of https://github.com/PotatoDumpl…
LucasSloan Oct 1, 2013
2124bd7
Changed testing syntax.
LucasSloan Dec 9, 2013
9bdf974
Merge branch 'postmovement' of https://github.com/PotatoDumplings/les…
LucasSloan Dec 9, 2013
ce3d6ff
Merge branch 'master' of https://github.com/tricycle/lesswrong into p…
LucasSloan Dec 9, 2013
5e5f092
Variety of small changes for readability.
LucasSloan Dec 9, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Variety of small changes for readability.
  • Loading branch information
LucasSloan committed Dec 9, 2013
commit 5e5f092aee47a64dbbae700327b8f530ad8d7408
2 changes: 1 addition & 1 deletion r2/r2/controllers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def POST_move(self, res, thing, destination, reason, ip):
currlink = Link._byID(thing.link_id)
currlink._incr('_descendant_karma', -(thing._descendant_karma + thing._ups - thing._downs))
destination._incr('_descendant_karma', thing._descendant_karma + thing._ups - thing._downs)
if hasattr(thing, 'parent_id'):
if hasattr(thing, 'parent_id') and thing.parent_id is not None:
parent = Comment._byID(thing.parent_id)
parent.incr_descendant_karma([], -(thing._descendant_karma + thing._ups - thing._downs))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pylons gives me an error here when I try to move a comment thread to a different article:

Module r2.lib.jsonresponse:181 in _Json        
>>  val = func(self, res, *a, **kw)
Module r2.controllers.validator.validator:78 in newfn        
>>  return fn(self, *a, **kw)
Module r2.controllers.api:229 in POST_move        
>>  currlink._incr('_descendant_karma', -(thing._descendant_karma + thing._ups - thing._downs))
Module r2.lib.db.thing:497 in __getattr__        
>>  return DataThing.__getattr__(self, attr)
Module r2.lib.db.thing:124 in __getattr__        
>>  raise AttributeError, '%s not found' % attr
<type 'exceptions.AttributeError'>: _descendant_karma not found 

I had created a couple of articles while on the master branch, then switched to the postmovement branch and tried to move some comments around and got this error. Perhaps it is relying on something that is not being set by current (in production) code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to run a script in the sql folder to add descendant karma to the SQL database.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you need #94.

else:
Expand Down
2 changes: 1 addition & 1 deletion r2/r2/lib/db/tdb_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ def get_thing(type_id, thing_id):
#if single, only return one storage, otherwise make a dict
res = {} if not single else None
for row in r:
if type_id in (1, 7):
if type_id in (types_name["link"].type_id, types_name["comment"].type_id):
stor = storage(ups = row.ups,
downs = row.downs,
date = row.date,
Expand Down
5 changes: 2 additions & 3 deletions r2/r2/lib/pages/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,9 +1045,8 @@ def __init__(self, link_name='', captcha=None, action = 'comment'):

class MoveBox(Wrapped):
"""Used on LinkInfoPage to render the move thread form."""
def __init__(self, link_name='', captcha=None, action = 'comment'):
Wrapped.__init__(self, link_name = link_name, captcha = captcha,
action = action)
def __init__(self, link_name='', captcha=None):
Wrapped.__init__(self, link_name = link_name, captcha = captcha)

class CommentListing(Wrapped):
"""Comment heading and sort, limit options"""
Expand Down
8 changes: 4 additions & 4 deletions r2/r2/models/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,8 +977,6 @@ def _move(cls, comment, currlink, newlink, top=False):
comment.link_id = newlink._id
comment.sr_id = newlink.sr_id

comment._commit()

if not top:
parent = Comment._byID(comment.parent_id)
comment.parent_permalink = parent.make_anchored_permalink(Link._byID(parent.link_id), Subreddit._byID(parent.sr_id))
Expand Down Expand Up @@ -1087,8 +1085,10 @@ def has_children(self):
return len(child)>0

def recursive_move(self, origin, destination, top=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to infer origin from self somehow and avoid passing in an extra parameter?

What are the types of origin (if it's required) and destination, and can you document that in a docstring?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could, but then we'd needlessly increase the number of calls to query. I think that this way is better.

q = Comment._query(Comment.c.parent_id == self._id)
children = list(q)
"""Self is the current comment. Origin is the link we're
moving the comment from. Destination is the link we're
moving the comment to."""
children = Comment._query(Comment.c.parent_id == self._id)

Comment._move(self, origin, destination, top)

Expand Down