Exemplo n.º 1
0
def pin_change_do(Req):
    if not Req.user.is_authenticated():
             return denied(Req)
     
    Form = PinChangeForm(Req.POST,  user = Req.user)  
    Dict = {}
    
    if Form.is_valid():
          pin_name = settings.ROOT_PATH + "pins_images/pin_%i.png" % (Req.user.id)
          (Letters, Value) = pin(pin_name)
          i = None
          try:
                  i = PinsImages.objects.get(user = Req.user)
          except PinsImages.DoesNotExist:
                  i = PinsImages(user = Req.user,
                                 img = pin_name
                                 )
          
          i.req_vocabulary  = Letters
          i.hash_value = generate_key_from(Value, settings.PIN_SALT)
          i.operator = Req.user
          i.status = "processed"
          i.save()
                ##устанавливаем холд на вывод 
          Key = start_show_pin(Req.user.id, 160000)      
          return redirect( "/pin_image_page/%s" % (Key) ) 
    else :
        t = loader.get_template("simple_form.html")   
        Dict = {}
        Dict["form"] = Form.as_p()
        Dict["action"] = "/profile/pin_change_do"
        Dict["action_title"] = settings.pin_change_title
        Dict["pin_load"] = True
        return http_tmpl_context(Req, t, Dict)
Exemplo n.º 2
0
def forgot_action(request):
    Form = UsersForgotMail(request.POST)  
    Dict = {}
    if Form.is_valid():
# Save a new Article object from the form's data.
        hold = HoldsWithdraw(user = Form.user, hours =  settings.default_hold)
        hold.save()
        NewPwd = generate_key("hold")[10:30]
        #if settings.DEBUG is False:
        Email = Form.cleaned_data["email"]
        send_mail(_(u'Обновление пароля на сайте ' + settings.BASE_HOST),
                                   reset_pwd_mail(Form.user, NewPwd),
                                   settings.EMAIL_HOST_USER,
                                   [ Email ],
                                     fail_silently = False)       
                
        Form.user.set_password(NewPwd)
        Form.user.save()        
        return redirect("/forgot_success")                
    else :
        t = loader.get_template("simple_form.html")   
        Dict["title"] = settings.secondary_main_forgot    
        Dict["form"] = Form.as_p()
        Dict["common_help_text"] = settings.common_help_text   
        Dict["action"] = "/forgot_action"
        Dict["action_title"] = settings.reset_password_title
        return http_tmpl_context(request, t, Dict)    
Exemplo n.º 3
0
def crypto_balances(request, CurrencyTitle):
    ###TODO add generator
    CurrencyInstance = Currency.objects.get(title=CurrencyTitle)
    BalancesList = []
    for item in Balances.objects.filter(currency=CurrencyInstance).exclude(account="whole").order_by("-balance"):
        Cell = []
        Cell.append(item.account)
        Cell.append(format_numbers_strong(item.balance))
        BalancesList.append({"transes": Cell})

    paginator = Paginator(BalancesList, 200)  # Show 25 contacts per page

    page = request.GET.get('page', 1)
    try:
        BalancesListPage = paginator.page(page)
    except PageNotAnInteger:
        # If page is not an integer, deliver first page.
        BalancesListPage = paginator.page(1)
    except EmptyPage:
        # If page is out of range (e.g. 9999), deliver last page of results.
        BalancesListPage = paginator.page(paginator.num_pages)
    balance = Balances.objects.get(account="whole", currency=CurrencyInstance)
    Dict = {"trans_page_title": _(u"Балансы  {currency} - общий {balance}").format(currency=CurrencyTitle,
                                                                                   balance=format_numbers_strong(
                                                                                       balance.balance)),
            "paging": True,
            "Trans": BalancesListPage,
            "TransList": BalancesListPage.object_list,
            "TransTitle": [{"value": _(u"Адрес")}, {"value": _(u"Баланс")}]
    }
    tmpl = loader.get_template("common_trans_page.html")
    return http_tmpl_context(request, tmpl, Dict)
Exemplo n.º 4
0
def depmotion(request, CurrencyTitle):
    CurrencyList = Currency.objects.all()
    cur = Currency.objects.get(title=CurrencyTitle)
    (TransList, TransTitle) = (None, None)
    user_id = request.user.id
    if SDKCryptoCurrency.has_key(CurrencyTitle):
        ##TODO avoid this
        TransList = list(crypton_currency_list(user_id, CurrencyTitle))
        TransTitle = (
            {"value": _(u"Дебит/Кредит")},
            {"value": _(u"Адрес")},
            {"value": _(u"Сумма")},
            {"value": _(u"Дата")},
            {"value": _(u"Статус")},
            {"value": _(u"Подтверждения")},
            {"value": _(u"Txid")},
        )
    elif CurrencyTitle == "UAH":
        TransList = list(crypton_uah_list(user_id))
        TransTitle = (
            {"value": _(u"Дебит/Кредит")},
            {"value": _(u"Счет")},
            {"value": _(u"Сумма")},
            {"value": _(u"Дата")},
            {"value": _(u"Статус")},
        )
    else:
        TransList = list(crypton_emoney_list(user_id, cur))
        TransTitle = (
            {"value": _(u"Дебит/Кредит")},
            {"value": _(u"Сумма")},
            {"value": _(u"Дата")},
            {"value": _(u"Статус")},
        )

    TransListPage = None
    paginator = Paginator(TransList, 200)  # Show 25 contacts per page

    page = request.GET.get("page", 1)

    try:
        TransListPage = paginator.page(page)
    except PageNotAnInteger:
        # If page is not an integer, deliver first page.
        TransListPage = paginator.page(1)
    except EmptyPage:
        # If page is out of range (e.g. 9999), deliver last page of results.
        TransListPage = paginator.page(paginator.num_pages)
    # balance =  Balances.objects.get(account = "whole", currency = CurrencyInstance)

    Dict = {
        "paging": True,
        "current_trade": CurrencyTitle,
        "Trans": TransListPage,
        "TransList": TransListPage.object_list,
        "TransTitle": TransTitle,
        "CurrencyList": CurrencyList,
    }
    tmpl = loader.get_template("finance_depmotion_home.html")
    return http_tmpl_context(request, tmpl, Dict)
def forgot_action(request):
    Form = UsersForgotMail(request.POST)
    Dict = {}
    if Form.is_valid():
        # Save a new Article object from the form's data.

        SessionLink = generate_key("hold")[10:30]
        reset_link = ResetPwdLink(user=Form.user, key=SessionLink)
        reset_link.save()
        # if settings.DEBUG is False:
        Email = Form.cleaned_data["email"]

        main.msgs.send_mail(
            _(u"Обновление пароля на бирже " + settings.BASE_HOST),
            reset_pwd_mail(Form.user, SessionLink),
            settings.EMAIL_HOST_USER,
            [Email],
            fail_silently=False,
        )

        return redirect("/forgot_success")
    else:
        t = loader.get_template("simple_form_center.html")
        Dict["title"] = settings.secondary_main_forgot
        Dict["form"] = Form.as_p()
        Dict["common_help_text"] = settings.common_help_text
        Dict["action"] = "/forgot_action"
        Dict["action_title"] = settings.reset_password_title
        return http_tmpl_context(request, t, Dict)
Exemplo n.º 6
0
def user_private_key(Req):
    Res =  ApiKeys.objects.get(user = Req.user)
    Dict = {}
    t = loader.get_template("ajax_simple_msg.html")   
    Dict = {}
    Dict["title"] = "Private API Key"
    Dict["simple_msg"] = Res.private_key
    return http_tmpl_context(Req, t, Dict)    
Exemplo n.º 7
0
def news_one(Req, Name):
    Dict = {}
    Res = NewsPage.objects.get(eng_title=Name)
    Dict["page"] = Res
    Dict["keywords"] = Res.meta_keyword
    Dict["description"] = Res.meta_description
    t = loader.get_template("page.html")
    return http_tmpl_context(Req, t, Dict)
Exemplo n.º 8
0
def profile(request, UserName):
   if not request.user.is_authenticated():
          return denied(request)
  
   Dict = {}

   for setting  in UserCustomSettings.objects.filter(user  = request.user):
           if setting.value != "no":
                        Dict[ setting.setting.title ]  = True
                        Dict[ setting.setting.title +"_value" ]  = setting.value
                        
   if request.user.username == UserName:
          t = loader.get_template("profile.html")   
          Dict = setup_user_menu(request.user, Dict)
          Class  = UserCustomSettings.objects.get(user  = request.user, setting__title="class")
          Identity  = UserCustomSettings.objects.get(user  = request.user, setting__title="identity")
          Res =  ApiKeys.objects.get(user = request.user)
          Dict["public_key_api"] = Res.public_key
          Dict["class_value"] = Class.value
          Dict["identity_value"] = Identity.value
          DealComis =  format_numbers4( Decimal(Dict["deal_comission_value"])*Decimal("100") )
          request.session["deal_comission_show"] = DealComis
          request.session["deal_comission"] = format_numbers4( Decimal(Dict["deal_comission_value"]))
          Dict["deal_comission_value"] = DealComis
          

          
          Dict["is_own_profile"] = True
          Dict["client"] = request.user
          return http_tmpl_context(request, t, Dict)    
   else:
          t = loader.get_template("profile.html")
          Dict = setup_user_menu(request.user)
          try:
                usr = User.objects.get(username  = UserName)
                Class  = UserCustomSettings.objects.get(user  = usr, setting__title="class")
                Dict["client"] = usr
                Dict["class_value"] = Class.value

          except :
                return denied(request)                
                
          Dict["is_own_profile"] = False

          return http_tmpl_context(request, t, Dict) 
def forgot(Req):
    t = loader.get_template("simple_form_center.html")
    Dict = {}
    Dict["title"] = settings.secondary_main_forgot
    forgotForm = UsersForgotMail()
    Dict["form"] = forgotForm.as_p()
    Dict["common_help_text"] = settings.common_help_text
    Dict["action"] = "/forgot_action"
    Dict["action_title"] = settings.reset_password_title
    return http_tmpl_context(Req, t, Dict)
Exemplo n.º 10
0
def page_private_key(Req):
     Use = False
     if Req.session.has_key("use_f2a") :
        Use = Req.session["use_f2a"]
     
     t = loader.get_template("common_secure_page_api.html")        
     Dict = {}
     Dict["type"] = "show_privat_key"
     Dict["key"] = generate_key()
     Dict["pin_load"] = not Use
     Dict["use_f2a"] =  Use
     return http_tmpl_context(Req, t, Dict ) 
Exemplo n.º 11
0
def pin_change(Req):
        if not Req.user.is_authenticated():
          return denied(Req)
  
        t = loader.get_template("simple_form.html")   
        Form = PinChangeForm(user = Req.user)  
        Dict = {}
        Dict["form"] = Form.as_p()
        Dict["action"] = "/profile/pin_change_do"
        Dict["action_title"] = settings.pin_change_title
        Dict["pin_load"] = True
        return http_tmpl_context(Req, t, Dict)
Exemplo n.º 12
0
def registration_ref(Req, Reference=None):
    if Req.user.is_authenticated():
        return redirect("/stock")

    Req.session['reference'] = Reference

    t = loader.get_template("registration.html")
    Dict = {}
    Dict["title"] = settings.secondary_main

    regisForm = UsersRegis(initial={"reference": Reference})
    Dict["regis_form"] = regisForm.as_p()
    return http_tmpl_context(Req, t, Dict)
Exemplo n.º 13
0
def reset_pwd(request, Key):
    Form = UsersForgotLinkPswd()
    try:
        link = ResetPwdLink.objects.get(key=Key, status="created")
        Dict = {}
        Dict["title"] = my_messages.secondary_main_forgot_link
        Dict["form"] = Form.as_p()
        Dict["common_help_text"] = my_messages.forgot_main_help_text
        Dict["action"] = "/reset_pwd_action/" + Key
        Dict["action_title"] = my_messages.forgot_main_update
        t = loader.get_template("simple_form_center.html")
        return http_tmpl_context(request, t, Dict)
    except ResetPwdLink.DoesNotExist:
        return redirect("/reset_link_no_found")
Exemplo n.º 14
0
def fin_regis(Req, key):
    try :
        f = ActiveLink.objects.get(key = key,status="created")    
        f.user.is_active = True
        f.user.save()
        f.status = "processed"
        f.save()
        new_api_key(f.user)
        
        t = loader.get_template("finished_success_registration.html")   
        new_pin = PinsImages(user = f.user)
        f.user.backend = 'django.contrib.auth.backends.ModelBackend'
        login(Req, f.user)        
        ShowKey =  new_pin4user(new_pin, f.user)
        Dict = {}
        Dict["title"] = settings.secondary_regis_finish_success
        Dict["pin"] = ShowKey
        return http_tmpl_context(Req, t, Dict) 
    except: 
        t = loader.get_template("finished_error_registration.html")   
        Dict = {}
        Dict["title"] = settings.secondary_regis_finish_error
        return http_tmpl_context(Req, t, Dict)     
Exemplo n.º 15
0
def try_regis(Req):
    Form = UsersRegis(Req.POST)

    if Form.is_valid():
        # Save a new Article object from the form's data.
        regis_new_user(Req, Form)
        return redirect("/regis_success")

    else:
        t = loader.get_template("registration.html")
        Dict = {}
        Dict["title"] = settings.secondary_regis
        Dict["regis_form"] = Form.as_p()
        return http_tmpl_context(Req, t, Dict)
Exemplo n.º 16
0
def notification(Req):
         if not Req.user.is_authenticated():
             return denied(Req)  
         else:
             t = loader.get_template("notify.html")   
             Dict = {}
             caching().delete("balance_" + str(Req.user.id) )
             List = list(main.models.Msg.objects.filter(user_to = Req.user,user_from_id = 1, user_hide_to = "false" ))
             page = Req.GET.get('page', 1)
             PageObject = my_cached_paging("notify_" + str(Req.user.id), main.models.Msg, page, List)
             Dict["msgs"] = PageObject.object_list
             Dict["paging"] = PageObject       
             main.models.Msg.objects.filter(user_to = Req.user,user_from_id = 1, user_hide_to = "false" ).update(user_seen_to  = "true")
             return http_tmpl_context(Req, t, Dict ) 
Exemplo n.º 17
0
def refs(request):
    
    (TransList,TransTitle) = (None, None)
   
    TransList = user_ref_list(request.user.id)
    TransTitle = ( {"value":_(u"Пользователь")},{"value":_(u"URL from")}, {"value":_(u"Дата регистрации")}, )
   
    
    Dict = {
             "TransList":   TransList,
             "TransTitle":  TransTitle,
            }
    tmpl = loader.get_template("finance_partners_list.html") 
    return http_tmpl_context(request, tmpl, Dict)     
Exemplo n.º 18
0
def msgs_in(Req):
          if not Req.user.is_authenticated():
             return denied(Req)  
          else:
             t = loader.get_template("msgs.html")   
             Dict = {}
             List = list(main.models.Msg.objects.filter(user_to = Req.user, user_hide_to = "false" ).exclude(user_from_id = 1))
             Dict["msg_in_count"] = len(List)
             Dict["msg_out_count"] = main.models.Msg.objects.filter(user_from = Req.user, user_hide_from = "false" ).exclude(user_to_id = 1).count()

             Dict["is_msg_in"] = True
             page = Req.GET.get('page', 1)
             PageObject = my_cached_paging("msgs_in_" + str(Req.user.id), main.models.Msg, page,  List)
             Dict["msgs"] = PageObject.object_list
             Dict["paging"] = PageObject          
             
             main.models.Msg.objects.filter(user_to = Req.user, user_hide_to = "false" ).update(user_seen_to  = "true")
             return http_tmpl_context(Req, t, Dict ) 
Exemplo n.º 19
0
def stock(Req, Title="btc_uah"):
    if Title is None:
        Title = Req.session.get('stock_path', None)
        if Title is None:
            Title = "btc_uah"
            Req.session['stock_path'] = Title

    t = loader.get_template("index.html")

    Dict = setup_trades_pairs(Title)
    # Dict = setup_common_orders(Req, Title, Dict )
    Dict["current_stock"] = Title
    Dict["title"] = settings.secondary_main
    Dict["trade_pair"] = Title
    Dict["help"] = True
    Dict["usd_uah_rate"] = get_memory_var("usd_uah_rate")
    Req.session['stock_path'] = Title

    return http_tmpl_context(Req, t, Dict)
Exemplo n.º 20
0
def reset_pwd_action(request, Key):
    link = None
    try:
        link = ResetPwdLink.objects.get(key=Key, status="created")
    except:
        return redirect("/reset_link_no_found")
    Form = UsersForgotLinkPswd(request.POST)
    Dict = {}
    if Form.is_valid():
        link.status = "processed"
        passwd = Form.cleaned_data["password1"]
        link.user.set_password(passwd)
        link.user.save()
        link.save()
        return redirect("/reset_success")
    else:
        t = loader.get_template("simple_form_center.html")
        Dict["title"] = my_messages.secondary_main_forgot_link
        Dict["form"] = Form.as_p()
        Dict["common_help_text"] = my_messages.forgot_main_help_text
        Dict["action"] = "/reset_pwd_action/" + Key
        Dict["action_title"] = my_messages.forgot_main_update
        return http_tmpl_context(request, t, Dict)
Exemplo n.º 21
0
def login_page(request):
    if request.user.is_authenticated():
        return redirect("/stock")
    t = loader.get_template("login_page.html")
    Dict = {}
    return http_tmpl_context(request, t, Dict)
Exemplo n.º 22
0
def pin_image_page(request, Key):
        Dict = {}
        t = loader.get_template("pin_page.html")
        Dict["title"] = settings.pin_page
        Dict["pin"] = Key
        return http_tmpl_context(request, t, Dict)
Exemplo n.º 23
0
def my_custom_error_view(request):
    t = loader.get_template('simple_msg.html')
    return http_tmpl_context(request, t, {"title": _("500,хм..."),
                                          "msg": _(u"Произошла какая-то странная ошибка,\
                                                    и мы о ней уже знаем, и побежали исправлять")})
Exemplo n.º 24
0
def news_cat(Req, i):
    t = loader.get_template("news_page.html")
    return http_tmpl_context(Req, t, {"category": i})
Exemplo n.º 25
0
def index(Req):
    t = loader.get_template("index.html")
    Dict = {}
    Dict["pagetitle"] = settings.pagetitle_main
    Dict["title"] = settings.pagetitle_home
    return http_tmpl_context(Req, t, Dict)
Exemplo n.º 26
0
def crypto_balances_home(request):
    t = loader.get_template("crypto_open_balances.html")
    Dict = {}
    Dict["pagetitle"] = _(u"Публичная информация о балансах криптовалют")
    Dict["CurrencyList"] = Currency.objects.exclude(id=1)
    return http_tmpl_context(request, t, Dict)
Exemplo n.º 27
0
def regis_success(Req):
    t = loader.get_template("success_registration.html")
    Dict = {}
    Dict["title"] = settings.secondary_regis_success
    return http_tmpl_context(Req, t, Dict)
Exemplo n.º 28
0
def news(Req):
    t = loader.get_template("news_page.html")
    return http_tmpl_context(Req, t, {})
Exemplo n.º 29
0
def page_discuss(Req, Id):
    Dict = {}
    Res = StaticPage.objects.get(id=int(Id))
    Dict["page"] = Res
    t = loader.get_template("page_discuss.html")
    return http_tmpl_context(Req, t, Dict)
Exemplo n.º 30
0
def page_help(Req):
    Dict = {}
    t = loader.get_template("page_help.html")
    Dict["title"] = settings.help_page
    return http_tmpl_context(Req, t, Dict)