Exemplo n.º 1
0
 def edit(self, request):
     gist = self.gist
     user = request.user
     if not user or user.username != gist.owner_id:
         raise AccessError()
     if request.method == 'POST':
         desc, is_public, names, contents, oids = _get_req_gist_data(
             request)
         gist.update(desc, names, contents, oids)
         return request.redirect(gist.url)
     tdt = dict(request=request, gist=gist, user=user)
     if is_mobile_device(request):
         return st('/m/gist/edit.html', **tdt)
     return st('/gist/edit.html', **tdt)
Exemplo n.º 2
0
 def edit(self, request):
     gist = self.gist
     user = request.user
     if not user or user.username != gist.owner_id:
         raise AccessError()
     if request.method == 'POST':
         desc, is_public, names, contents, oids = _get_req_gist_data(
             request)
         gist.update(desc, names, contents, oids)
         return request.redirect(gist.url)
     tdt = dict(request=request, gist=gist, user=user)
     if is_mobile_device(request):
         return st('/m/gist/edit.html', **tdt)
     return st('/gist/edit.html', **tdt)
Exemplo n.º 3
0
def _q_index(request):
    user = request.user
    if request.method == 'POST':
        desc, is_public, names, contents, oids = _get_req_gist_data(request)
        user = request.user
        owner_id = user and user.username or Gist.ANONYMOUS
        gist = Gist.add(desc, owner_id, is_public, names, contents)
        return request.redirect(gist.url)

    tdt = dict(request=request, gists=[], user=user)
    if user:
        gists = Gist.gets_by_owner(user.username, limit=4)
        tdt.update(dict(gists=gists))

    if is_mobile_device(request):
        return st('/m/gist/index.html', **tdt)
    return st('/gist/index.html', **tdt)
Exemplo n.º 4
0
def _q_index(request):
    user = request.user
    if request.method == 'POST':
        desc, is_public, names, contents, oids = _get_req_gist_data(request)
        user = request.user
        owner_id = user and user.username or Gist.ANONYMOUS
        gist = Gist.add(desc, owner_id, is_public, names, contents)
        return request.redirect(gist.url)

    tdt = dict(request=request, gists=[], user=user)
    if user:
        gists = Gist.gets_by_owner(user.username, limit=4)
        tdt.update(dict(gists=gists))

    if is_mobile_device(request):
        return st('/m/gist/index.html', **tdt)
    return st('/gist/index.html', **tdt)
Exemplo n.º 5
0
 def _render(self, request, gists):
     user = self.user
     tdt = {
         'request': request,
         'gists': gists,
         'user': user,
         'page': int(self.page),
         'link_prev': self.link_prev,
         'link_next': self.link_next,
         'n_all': self.n_all,
         'n_fork': self.n_fork,
         'n_star': self.n_star,
         'sort': self.sort,
         'direction': self.direction
     }
     if is_mobile_device(request):
         return st('/m/gist/user_gists.html', **tdt)
     return st('/gist/user_gists.html', **tdt)
Exemplo n.º 6
0
 def _render(self, request, gists):
     user = self.user
     tdt = {
         'request': request,
         'gists': gists,
         'user': user,
         'page': int(self.page),
         'link_prev': self.link_prev,
         'link_next': self.link_next,
         'n_all': self.n_all,
         'n_fork': self.n_fork,
         'n_star': self.n_star,
         'sort': self.sort,
         'direction': self.direction
     }
     if is_mobile_device(request):
         return st('/m/gist/user_gists.html', **tdt)
     return st('/gist/user_gists.html', **tdt)
Exemplo n.º 7
0
    def start_request(self, request):
        Publisher.start_request(self, request)
        os.environ['SQLSTORE_SOURCE'] = request.get_url()

        resp = request.response
        resp.set_content_type('text/html; charset=utf-8')
        resp.set_header('Pragma', 'no-cache')
        resp.set_header('Cache-Control', 'must-revalidate, no-cache, private')
        # FIXME: quixote with origin?
        resp.set_header('Access-Control-Allow-Origin', '*')
        request.enable_ajax = False
        request.browser = request.guess_browser_version()
        request.method = request.get_method()
        request.url = request.get_path()
        request.is_mobile = is_mobile_device(request)
        request.start_time = time.time()
        request.user = User.check_session(request)

        import_obj_set("request", request)
Exemplo n.º 8
0
    def start_request(self, request):
        Publisher.start_request(self, request)
        os.environ['SQLSTORE_SOURCE'] = request.get_url()

        resp = request.response
        resp.set_content_type('text/html; charset=utf-8')
        resp.set_header('Pragma', 'no-cache')
        resp.set_header('Cache-Control', 'must-revalidate, no-cache, private')
        # FIXME: quixote with origin?
        resp.set_header('Access-Control-Allow-Origin', '*')
        request.enable_ajax = False
        request.browser = request.guess_browser_version()
        request.method = request.get_method()
        request.url = request.get_path()
        request.is_mobile = is_mobile_device(request)
        request.start_time = time.time()
        request.user = User.check_session(request)

        import_obj_set("request", request)
Exemplo n.º 9
0
 def _q_index(self, request):
     user = request.user
     tdt = dict(request=request, gist=self.gist, ref='master', user=user)
     if is_mobile_device(request):
         return st('/m/gist/gist_detail.html', **tdt)
     return st('/gist/gist_detail.html', **tdt)
Exemplo n.º 10
0
 def _q_index(self, request):
     user = request.user
     tdt = dict(request=request, gist=self.gist, ref='master', user=user)
     if is_mobile_device(request):
         return st('/m/gist/gist_detail.html', **tdt)
     return st('/gist/gist_detail.html', **tdt)