Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Like/dislike feature #115

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

killpanda
Copy link
Contributor

  • Add a pluggable Likes model
  • Add ajax api for this feature
  • Add some test

@killpanda
Copy link
Contributor Author

This PR is done.

@killpanda killpanda changed the title WIP: basic pluggable like model Like/Unlike feature Sep 15, 2015
@killpanda killpanda changed the title Like/Unlike feature Like/dislike feature Sep 15, 2015

@property
def product_id(self):
return str(self.productidgetter(self._instance))
Copy link
Member

Choose a reason for hiding this comment

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

这里等价于 return str(self._instance) 应该不是你预期的结果吧?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mozillazg 不是呀 这里是要通过 productidgetter 来拿到 product_id

Copy link
Contributor

Choose a reason for hiding this comment

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

@killpanda 其实我也没看懂. 在productidgetter 里面 直接返回了参数 不就是 @mozillazg 说的意思么

其次 productidgetter这个方法名字 不是应该用下划线分词的么 比如 product_id_getter

@dongweiming
Copy link
Contributor

@killpanda 辛苦

post = Post.objects.get_or_404(id=id)
if post:
post.likes.delete(current_user.id)
return '', 201
Copy link
Contributor

Choose a reason for hiding this comment

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

delete 应该也是204

@killpanda
Copy link
Contributor Author

大家看看现在怎么样?

@halfcrazy
Copy link
Member

@killpanda 现在清楚了不少。有一点,likes这个类,我觉得除了add delete方法要操作数据库,是不是还可以在内部维护一个list/set便于直接取用户

@killpanda
Copy link
Contributor Author

@halfcrazy 可以举个例子来说说用法吗?

@halfcrazy
Copy link
Member

@killpanda 知乎问题右边的,xxx,xxx关注了本问题

@killpanda
Copy link
Contributor Author

@halfcrazy 加了个 __getitem__,其它功能随用随加吧 XD

@halfcrazy
Copy link
Member

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants