Пример #1
0
def user_update(request, context={}):

    developer = context["developer"]

     # POST
    if request.method == 'POST':
        #developer = models.DeveloperModel()
        form = RegistFormUpdate(request.POST)

        if form.is_valid():
            params = form.cleaned_data
            params["user_id"] = developer.user_id
            params["status"]  = 1
            Developer.save(params, developer)
            return HttpResponseRedirect(reverse(views.dev.index))
        else:
            context["form"] = form
            return render_to_response('webfront/regist_form.html', context)

    # GET
    else:
        form = RegistFormUpdate()
        form.setParams(developer)

        context["form"] = form
        return render_to_response('webfront/regist_form.html', context)
Пример #2
0
def form(request):
    context = RequestContext(request, {
        "form": "",
        "title": u"部員登録"
    })
    user = users.get_current_user()
    # 登録済みならリダイレクト
    if Developer.getByUserId(user.user_id()):
        return HttpResponseRedirect(reverse(views.dev.index))
    # POST
    if request.method == 'POST':
        #developer = models.DeveloperModel()
        form = RegistFormFirst(request.POST)
        if form.is_valid():
            params = form.cleaned_data
            params["user_id"] = user.user_id()
            params["status"]  = 1

            developer = Developer.save(params)
            return HttpResponseRedirect(reverse(complete))
        else:
            context["form"] = form
            return render_to_response('webfront/regist_form.html', context)
    # GET
    else:
        form = RegistFormFirst(initial={
            'uname': user.nickname(),
            'email': user.email()
        })
        context["form"] = form
        return render_to_response('webfront/regist_form.html', context)
Пример #3
0
def _getDeveloper(option):
    if "developer_id" in option:
        developer = Developer.get_by_id(option["developer_id"])
    else:
        developer = Developer.getByAlias(option["developer_alias"])
    if not developer:
        return False
    return Developer
Пример #4
0
def _detail_developer(request, option={}):
    if "developer_id" in option:
        developer = Developer.get_by_id(option["developer_id"])
    else:
        developer = Developer.getByAlias(option["developer_alias"])
    if not developer:
        return {"status": -2, "error": "invalid developer"}
    app = App.getQueryByDeveloper(developer.key.id())
    context["developer"] = developer
    context["apps"] = app
    context["platforms"] = platforms
Пример #5
0
def user_list(request, page, context):
    COUNT = 50
    query = Developer.getQuery()
    p = GAEPaginator(query, COUNT)
    context["page"] = page
    context["developers"] = p.page(page)
    return render_to_response("webfront/user_list.html", context)
Пример #6
0
def index(request, context):
    user = users.get_current_user()
    if not user:
        context["login_url"] = users.create_login_url(reverse(form))
    else:
        context["user_id"] = user.user_id()
        context["logout_url"] = users.create_logout_url(reverse(index))
    context["developers"] = Developer.getQuery().fetch(10)
    return render_to_response('webfront/regist.html',context)
Пример #7
0
def user(request, user_alias, context):
    developer = Developer.getByAlias(user_alias)
    if not developer:
        raise Http404
    app = App.getQueryByDeveloper(developer.key.id())
    context["developer"] = developer
    context["apps"] = app
    context["platforms"] = platforms
    return render_to_response("webfront/developer_detail.html", context)
Пример #8
0
def index(request, context):
    context["developers"] = Developer.getQuery().fetch(4)
    context["recent_apps"] = {}
    pickups = App.getPickup()
    context["pickup_apps"] = pickups[0:2]
    context["pickup_apps_after"] = pickups[2:]
    context["has_more"] = {}
    context["apps"] = App.getRecentQuery().fetch(18)
    return render_to_response("webfront/index.html", context)
Пример #9
0
 def override_view(request):        
     user = users.get_current_user()
     developer = None
     if user:
         developer = Developer.getByUserId(user.user_id())
     context = RequestContext(request,{
         "is_login": bool(user),
         "logout_page": reverse(views.regist.index),
         "developer" : developer,
         "current_tab": "dev",
     })
     return view(request, context)
Пример #10
0
def app_detail(request, app_id, context):
    app = App.getById(int(app_id))
    if not app or app.status != 1:
        raise Http404
    context["app"] = app
    developer = Developer.get_by_id(app.developer_id)
    # if not developer.status != 1:
    #    raise Http404
    context["developer"] = developer
    context["push_app"] = App.getPush(app.developer_id, app.platform)
    # 自身が含まれている可能性があるので +1件
    context["related_app"] = App.getRecentQuery(app.platform, app.category).fetch(3 + 1)
    return render_to_response("webfront/app_detail.html", context)
Пример #11
0
 def override_view(*args, **kwargs):
     request = args[0]
     user = users.get_current_user()
     developer = Developer.getByUserId(user.user_id())
     if not developer:
         return HttpResponseRedirect(reverse(views.regist.form))
     context = RequestContext(request,{
         "is_login": True,
         "logout_page": reverse(views.regist.index),
         "developer" : developer,
         "current_tab": "dev",
         "platforms": platforms,
         "show_status": show_status
     })
     kwargs["context"] = context
     return view(*args, **kwargs)
Пример #12
0
def _developer_apps(request, option={}):
    developer = Developer.getByAlias(option["developer_alias"])
    if not developer:
        return {"status": -2, "error": "invalid developer"}
    platform = arrays.get_platform_id(option["plat_str"])
    params = request.GET.copy()
    params["platform"] = platform
    form = apiform.RecentAppForm(params)
    if not form.is_valid():
        return {"status": -1, "thread_id":'', "error": form.errors}
    params = form.cleaned_data
    app = App.getQueryByDeveloper(developer.key.id(), params["platform"])
    return {
        "status": 1,
        "apps": sorted(app.fetch(params["count"], offset=params["offset"]), key=lambda x:x.created_at, reverse=True)
    }
Пример #13
0
def _detail_app(request, option = {}):
    app_id = long(option["app_id"])
    params = request.GET.copy()
    form = apiform.DetailAppForm(params)
    if not form.is_valid():
        return {"status": -1, "error": form.errors}
    params = form.cleaned_data
    app = App.get_by_id(app_id)
    if not app or app.status != 1:
        return {"status": -2, "error": "invalid app_id"}
    developer = Developer.get_by_id(app.developer_id)
    return {
        "status": 1,
        "app": app,
        "developer": developer,
    }
Пример #14
0
 def override_view(*args, **kwargs):
     request = args[0]
     user = users.get_current_user()
     developer = None
     if user:
         developer = Developer.getByUserId(user.user_id())
     context = RequestContext(
         request,
         {
             "is_login": bool(user),
             "logout_page": reverse(views.regist.index),
             "developer": developer,
             "platforms": platforms,
         },
     )
     kwargs["context"] = context
     return view(*args, **kwargs)
Пример #15
0
def user_id(request, user_id, context):
    developer = Developer.get_by_id(user_id)
    if not developer:
        raise Http404
    return HttpResponseRedirect(reverse(user, args=[developer.user_alias]))
Пример #16
0
def sitemap(request):
    context = RequestContext(request, {})
    context["apps"] = App.getRecentQuery(None)
    context["developers"] = Developer.getQuery()
    return render_to_response("webfront/sitemap.xml", context, mimetype="application/xml")