Example #1
0
    def decorate(request, *args, **kwds):
        """
        require_osuser
        """
        from django.core.urlresolvers import reverse
        from submodule.gsocial.http import HttpResponseOpensocialRedirect
        if settings.DEBUG and settings.OPENSOCIAL_SANDBOX and settings.IS_LOCAL_AUTH:
            if not request.user.is_authenticated():
                return HttpResponseOpensocialRedirect(
                    reverse('mobile_auth_login'), request)

        assert hasattr(
            request, 'opensocial_userid'
        ), "require_osuser requires singned_request or oauth_signature_required decolator."

        # ゲームができるユーザーの制限追加
        from gsocial.utils.restrictive.api import get_restrictive_api
        restrictive_api = get_restrictive_api(request.opensocial_userid)
        #        return HttpResponseOpensocialRedirect(reverse('mobile_not_playable'), request)
        if not restrictive_api.can_playable():
            return HttpResponseOpensocialRedirect(
                reverse('mobile_not_playable'), request)

        # OpenSocialUserを取得する
        #osuser = get_osuser(request.opensocial_userid, request)
        request.osuser = get_osuser(request.opensocial_userid, request)
        return view_func(request, *args, **kwds)
Example #2
0
 def __init__(self, request, user_id=None):
     if user_id:
         self.osuser = get_osuser(user_id)
         if not self.osuser:
             raise AuthDeviceError('Can not find user. UserID=%s' % str(user_id))
     else:
         self.osuser = request.osuser
     self.user_id = self.osuser.userid
Example #3
0
 def decorate(request, *args, **kwds):
     if hasattr(request, 'opensocial_viewer_id'):
         opensocial_viewer_id = request.opensocial_viewer_id
     else:
         opensocial_viewer_id = request.REQUEST.get('opensocial_viewer_id')
         if not opensocial_viewer_id:
             opensocial_viewer_id = request.session['opensocial_userid']
     
     # Get OpenSocialUser
     # OpenSocialUserを取得する
     osuser = get_osuser(opensocial_viewer_id, request)
     request.osuser = osuser
         
     return view_func(request, *args, **kwds)
Example #4
0
    def decorate(request, *args, **kwds):
        if hasattr(request, 'opensocial_viewer_id'):
            opensocial_viewer_id = request.opensocial_viewer_id
        else:
            opensocial_viewer_id = request.REQUEST.get('opensocial_viewer_id')
            if not opensocial_viewer_id:
                opensocial_viewer_id = request.session['opensocial_userid']

        # Get OpenSocialUser
        # OpenSocialUserを取得する
        osuser = get_osuser(opensocial_viewer_id, request)
        request.osuser = osuser

        return view_func(request, *args, **kwds)
Example #5
0
    def payment(self, request, *args, **kwargs):
        """
        GREE にリダイレクトする.
        
        GachaView クラスでは,
        check -> payment -> gacha の順にメソッドを実行するが,
        HttpResponse を返すため, 続く gacha は実行されない.

        callback_path で設定した URL が GREE から呼ばれるので
        そこで gacha メソッドを実行し,
        redirect_path で設定した URL へユーザは遷移するので
        そこで gacha メソッドの終了を待つ.
        """
        self.raise_if_none('item_id_base', 'item_name', 'item_description',
                           'redirect_path', 'media_path', 'callback_path')
        need_coin = self.get_amount(request, *args, **kwargs)
        self.write_log_debug(u'payment: need_coin = %s', need_coin)

        if settings.OPENSOCIAL_DEBUG:
            self.write_log_debug(u'payment: OPENSOCIAL_DEBUG is True')
            # こっそり, callback_path の View に redirect_path を伝える
            self.session.set('gree_coin_redirect_path', self.redirect_path)
            self.write_log_debug(u'payment: redirect to %s', self.callback_path)
            return HttpResponseOpensocialRedirect(self.callback_path)

        # submodule への依存は諦める
        self.write_log_debug(u'payment: opensocial_viewer_id = %s',
                             request.opensocial_viewer_id)
        osuser = get_osuser(request.opensocial_viewer_id, request)
        self.write_log_debug(u'payment: osuser = %s', osuser.userid)

        purchase_url = Payment(request).request_payment(
            osuser_id=osuser.userid,
            item_id=int(self.get_gacha_id()) + int(self.item_id_base),
            item_name=self.item_name,
            item_point=need_coin,
            item_description=self.item_description,
            item_image_url=self.media_path,
            callback_path=self.callback_path,
            finish_path=self.redirect_path,
            item_message='',
            item_quantity=self.item_quantity,
            is_test=False,
        )

        self.write_log_debug(u'payment: redirect to %s', purchase_url)
        return HttpResponseRedirect(purchase_url)
Example #6
0
    def decorate(request, *args, **kwds):

        """
        require_osuser
        """
        from django.core.urlresolvers import reverse
        from submodule.gsocial.http import HttpResponseOpensocialRedirect
        if settings.DEBUG and settings.OPENSOCIAL_SANDBOX and settings.IS_LOCAL_AUTH:
            if not request.user.is_authenticated():
                return HttpResponseOpensocialRedirect(reverse('mobile_auth_login'), request)

        assert hasattr(request, 'opensocial_userid'), "require_osuser requires singned_request or oauth_signature_required decolator."

        # ゲームができるユーザーの制限追加
        from gsocial.utils.restrictive.api import get_restrictive_api
        restrictive_api = get_restrictive_api(request.opensocial_userid)
#        return HttpResponseOpensocialRedirect(reverse('mobile_not_playable'), request)
        if not restrictive_api.can_playable():
            return HttpResponseOpensocialRedirect(reverse('mobile_not_playable'), request)

        # OpenSocialUserを取得する
        #osuser = get_osuser(request.opensocial_userid, request)
        request.osuser = get_osuser(request.opensocial_userid, request)
        return view_func(request, *args, **kwds)
Example #7
0
 def os_user(self):
     return get_osuser(self.opensocial_viewer_id, self._request)
Example #8
0
 def os_user(self):
     return get_osuser(self.opensocial_viewer_id, self._request)