Esempio n. 1
0
def favorite_btn(context, content_object, style_class="btn_1 favorite"):
    user = context['request'].user
    btn_name = _("FAVORITE")
    btn_name_un = _("UNFAVORITE")
    if not user.is_anonymous():
        show_btn=True
        action = 'follow'
        if is_following(user, content_object):
            action = 'unfollow'

        content_type_id = ContentType.objects.get_for_model(content_object).pk
        if content_type_id == ContentType.objects.get_for_model(User).pk:
            btn_name = _("FOLLOW")
            btn_name_un = _("UNFOLLOW")
            if not content_object.get_profile().viewable_by(user):
                show_btn = False
        
        return {
            'content_type_id' : content_type_id,
            'object_id' : content_object.pk,
            'action': action,
            'show_btn': show_btn,
            'btn_class': style_class,
            'btn_name': btn_name,
            'btn_name_un': btn_name_un
        } 
Esempio n. 2
0
def follow_btn(context, content_object):
    user = context['request'].user
    if not user.is_anonymous():
        action = 'follow'
        if is_following(user, content_object):
            action = 'unfollow'

        content_type_id = ContentType.objects.get_for_model(content_object).pk

        return {
            'content_type_id' : content_type_id,
            'object_id' : content_object.pk,
            'action': action,
		}