def add_current_user_is_applied_representation(func):
  """ Used to decorate Serializer.to_representation method.
      It sets the field "current_user_is_applied" if the user is applied to the project
  """
  @wraps(func)
  def _impl(self, instance):
    # We pop current_user_is_applied field to avoid AttributeError on default Serializer.to_representation
    ret = func(self, instance)

    user = self.context["request"].user
    applied = False
    if not user.is_anonymous():
      try:
        applied = models.Apply.objects.filter(user=user, project=instance).count() > 0
      except:
        pass

    ret["current_user_is_applied"] = applied

    return ret
  return _impl
Used to decorate Serializer.to_representation method.
      It sets the field "current_user_is_applied" if the user is applied to the project