Пример #1
0
def common_design_update(request, nick):
  view = api.actor_get(api.ROOT, nick)
  if request.POST:
    try:
      validate.nonce(request, 'update_design')

      color = request.POST.get('bg_color')
      repeat = request.POST.get('bg_repeat', 'no-repeat')
      if not repeat:
        repeat = ''

      img = request.FILES.get('bg_image')
      img_url = None
      if img:
        img_url = api.background_upload(request.user,
                                        nick,
                                        img.read())
      api.background_set_actor(request.user,
                               nick,
                               img_url,
                               color,
                               repeat)
      return util.RedirectFlash(view.url() + '/settings/design',
                                'design updated')
    except:
      exception.handle_exception(request)

  if request.GET and 'restore' in request.GET:
      api.background_clear_actor(request.user, nick)
      return util.RedirectFlash(view.url() + '/settings/design',
                                'design updated')

  return None
Пример #2
0
def common_design_update(request, success="/", nick=None):
  if not nick:
    nick = request.user.nick
  view = api.actor_get(api.ROOT, nick)
  if request.POST:
    try:
      validate.nonce(request, 'update_design')

      color = request.POST.get('bg_color')
      repeat = request.POST.get('bg_repeat', 'no-repeat')
      if not repeat:
        repeat = ''

      img = request.FILES.get('bg_image')
      img_url = None
      if img:
        img_url = api.background_upload(request.user,
                                        nick,
                                        img.read())
      api.background_set_actor(request.user,
                               nick,
                               img_url,
                               color,
                               repeat)
      return util.RedirectFlash(success,
                                'Thiết lập về màu nền/ảnh nền đã được cập nhật lại.')
    except:
      exception.handle_exception(request)

  if request.GET and 'restore' in request.GET:
      api.background_clear_actor(request.user, nick)
      return util.RedirectFlash(success,
                                'Thiết lập ảnh nền/màu nền đã được khôi phục về trạng thái mặc định.')

  return None
Пример #3
0
def common_design_update(request, nick):
    view = api.actor_get(api.ROOT, nick)
    if request.POST:
        try:
            validate.nonce(request, 'update_design')

            color = request.POST.get('bg_color')
            repeat = request.POST.get('bg_repeat', 'no-repeat')
            if not repeat:
                repeat = ''

            img = request.FILES.get('bg_image')
            img_url = None
            if img:
                img_url = api.background_upload(request.user, nick, img.read())
            api.background_set_actor(request.user, nick, img_url, color,
                                     repeat)
            return util.RedirectFlash(view.url() + '/settings/design',
                                      'design updated')
        except:
            exception.handle_exception(request)

    if request.GET and 'restore' in request.GET:
        api.background_clear_actor(request.user, nick)
        return util.RedirectFlash(view.url() + '/settings/design',
                                  'design updated')

    return None