def suggestion_approve(request, id): suggestion = get_object_or_404(Suggestion, id=id) # Todo move this into the model, not view! suggestion.status = Suggestion.APPROVED suggestion.status_timestamp = timezone.now() suggestion.save() icon = "<span class='fa-stack'>" + \ "<i class='fa fa-lightbulb-o fa-stack-1x'></i>" + \ "<i class='fa fa-check fa-stack-2x text-success'></i>" + \ "</span>" # TODO don't hardcode this, put it in the settings! suggestion_badge = get_object_or_404(Badge, pk=config.hs_suggestion_badge) grant_badge(request, suggestion_badge.id, suggestion.user.id) notify.send( request.user, # action=profile.user, target=suggestion, recipient=suggestion.user, affected_users=[ suggestion.user, ], verb='approved', icon=icon, ) messages.success(request, "Suggestion by " + str(suggestion.user) + " approved.") return redirect(suggestion.get_absolute_url())
def suggestion_approve(request, id): suggestion = get_object_or_404(Suggestion, id=id) suggestion.status = Suggestion.APPROVED suggestion.status_timestamp = timezone.now() suggestion.save() icon="<span class='fa-stack'>" + \ "<i class='fa fa-lightbulb-o fa-stack-1x'></i>" + \ "<i class='fa fa-check fa-stack-2x text-success'></i>" + \ "</span>" suggestion_badge = get_object_or_404(Badge, name="Human Baby") grant_badge(request, suggestion_badge.id ,suggestion.user.id) notify.send( request.user, # action=profile.user, target= suggestion, recipient=suggestion.user, affected_users=[suggestion.user,], verb='approved', icon=icon, ) messages.success(request, "Suggestion by " + str(suggestion.user) + " approved.") return redirect(suggestion.get_absolute_url())
def suggestion_approve(request, id): suggestion = get_object_or_404(Suggestion, id=id) # Todo move this into the model, not view! suggestion.status = Suggestion.APPROVED suggestion.status_timestamp = timezone.now() suggestion.save() icon = "<span class='fa-stack'>" + \ "<i class='fa fa-lightbulb-o fa-stack-1x'></i>" + \ "<i class='fa fa-check fa-stack-2x text-success'></i>" + \ "</span>" # TODO don't hardcode this, put it in the settings! suggestion_badge = get_object_or_404(Badge, pk=config.hs_suggestion_badge) grant_badge(request, suggestion_badge.id, suggestion.user.id) notify.send( request.user, # action=profile.user, target=suggestion, recipient=suggestion.user, affected_users=[suggestion.user, ], verb='approved', icon=icon, ) messages.success(request, "Suggestion by " + str(suggestion.user) + " approved.") return redirect(suggestion.get_absolute_url())
def check_votes_and_grant_badge(request, user): user_votes_this_sem = Vote.objects.all_this_semester(user).count() vote_badge = get_object_or_404(Badge, pk=config.hs_voting_badge) user_num_votes_badge = BadgeAssertion.objects.num_assertions(user, vote_badge, active_semester_only=True) votes_per_badge = config.hs_num_votes vote_badges_earned = int(user_votes_this_sem / votes_per_badge) if vote_badges_earned > user_num_votes_badge: grant_badge(request, vote_badge.id, user.id) return True else: return False
def check_votes_and_grant_badge(request, user): user_votes_this_sem = Vote.objects.all_this_semester(user).count() vote_badge = get_object_or_404(Badge, pk=config.hs_voting_badge) user_num_votes_badge = BadgeAssertion.objects.num_assertions( user, vote_badge, active_semester_only=True) votes_per_badge = config.hs_num_votes vote_badges_earned = int(user_votes_this_sem / votes_per_badge) if vote_badges_earned > user_num_votes_badge: grant_badge(request, vote_badge.id, user.id) return True else: return False