Example #1
0
from apiview import utility
from apiview.err_code import ErrCode
from apiview.exceptions import CustomError
from apiview.views import ViewSite, fields
from constance import config
from django.db import transaction
from django.db.models import Q

from apps.wechat import biz
from apps.wechat.views import UserBaseView
from core.constants import DELETE_CODE

from . import models, serializer, constants

site = ViewSite(name='meetings', app_name='meetings')


class BaseView(UserBaseView):
    @staticmethod
    def get_room_follow(room_id, user_id):
        follow, _ = models.UserFollowRoom.default_manager.get_or_create(
            room_id=room_id, user_id=user_id)
        return follow

    @staticmethod
    def get_date_time_settings():
        today = datetime.date.today()
        return {
            'start_time': config.RESERVE_START_TIME,
            'end_time': config.RESERVE_END_TIME,
Example #2
0
# encoding: utf-8
from __future__ import absolute_import, unicode_literals

from apiview import utility
from apiview.err_code import ErrCode
from apiview.exceptions import CustomError
from apiview.views import ViewSite, fields
from django.contrib.auth import authenticate, login

from core import utils

from . import biz, models, serializer

site = ViewSite(name='wechat', app_name='wechat')


@site
class Login(utils.APIBase):
    name = "小程序登录"

    def get_context(self, request, *args, **kwargs):
        session = biz.wechat.wxa.code_to_session(request.params.js_code)
        wxa_user, new = models.User.objects.get_or_create(
            openid=session['openid'])
        wxa_user.set_info(session)
        login_user = authenticate(request, openid=wxa_user.openid)
        if login_user is None:
            raise CustomError(ErrCode.ERR_COMMON_BAD_PARAM)
        login(request, login_user)
        return serializer.UserSerializer(wxa_user, request=request).data
# encoding: utf-8
from __future__ import absolute_import, unicode_literals

from apiview.views import ViewSite

from core import view

from . import biz

site = ViewSite(name='isv', app_name='apps.corp')


@site
class TestSyncCorp(view.AdminApi):
    def get_context(self, request, *args, **kwargs):
        biz.sync_corp()
        return 'ok'


urlpatterns = site.urlpatterns
Example #4
0
# encoding: utf-8
from __future__ import absolute_import, unicode_literals

from apiview.err_code import ErrCode
from apiview.exceptions import CustomError
from apiview.views import ViewSite, fields
from dingtalk.core.constants import SuitePushType
from django.contrib.auth import login, authenticate
from django.utils.encoding import force_text
from rest_framework.response import Response

from core import view, constants as core_constants
from example import celery
from . import models, constants, biz, cache, serializer

site = ViewSite(name='isv', app_name='apps.isv')


@site
class TestCorpInfo(view.AdminApi):
    def get_context(self, request, *args, **kwargs):
        return biz.sync_corp(request.params.corp_pk)

    class Meta:
        param_fields = (('corp_pk',
                         fields.IntegerField(help_text='corp_pk',
                                             required=True)), )


@site
class SuiteCallback(view.APIBase):