Exemple #1
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 ) 
Exemple #2
0
def notification(Req):
    if not Req.user.is_authenticated():
        return denied(Req)
    else:
        t = loader.get_template("notify.html")
        Dict = {}
        tornadocache_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)
Exemple #3
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 ) 
Exemple #4
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)
Exemple #5
0
def trans(Req):
    t = loader.get_template("finance_trans.html")
    Dict = {}
    ListAccounts = []
    DictAccounts = {}
    for i in Accounts.objects.filter(user=Req.user):
        ListAccounts.append(str(i.id))
        DictAccounts[i.id] = 1
    AccountsStr = ",".join(ListAccounts)

    Query = (
        "SELECT * FROM main_trans WHERE 1 \
                               AND status in ('payin','deposit','withdraw','deal','order_cancel','comission','bonus','deal_return')\
                               AND ( user1_id IN (%s) OR user2_id IN  (%s) ) ORDER BY id DESC  "
        % (AccountsStr, AccountsStr)
    )

    List = Trans.objects.raw(Query)
    All = []
    for item in List:

        new_item = {}
        new_item["description"] = generate_description(DictAccounts, item)
        new_item["amnt"] = format_numbers_strong(item.amnt)
        new_item["currency"] = item.currency.title

        new_item["ts"] = formats.date_format(item.pub_date, "DATETIME_FORMAT")
        new_item["id"] = item.id
        new_item["in"] = False
        if DictAccounts.has_key(item.user2_id):
            new_item["in"] = True
        All.append(new_item)

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

    PageObject = my_cached_paging("user_id_trans" + str(Req.user.id), Trans, page, All)

    Dict["trans_list"] = PageObject.object_list
    Dict["paging"] = PageObject

    return tmpl_context(Req, t, Dict)
Exemple #6
0
def trans(Req):
    t = loader.get_template("finance_trans.html")
    Dict = {}
    user_id =  Req.user.id
    ListAccounts = []
    DictAccounts = {}
    for i in Accounts.objects.filter(user_id=user_id):
        ListAccounts.append(str(i.id))
        DictAccounts[i.id] = 1
    AccountsStr = ",".join(ListAccounts)

    Query = "SELECT * FROM main_trans WHERE 1 \
                               AND status in ('payin','deposit','withdraw','deal','order_cancel','comission','bonus','deal_return')\
                               AND ( user1_id IN (%s) OR user2_id IN  (%s) ) ORDER BY id DESC  " % (
    AccountsStr, AccountsStr)

    List = Trans.objects.raw(Query)
    All = []
    for item in List:

        new_item = {}
        new_item["description"] = generate_description(DictAccounts, item)
        new_item["amnt"] = format_numbers_strong(item.amnt)
        new_item["currency"] = item.currency.title

        new_item["ts"] = int((item.pub_date - datetime.datetime(1970,1,1)).total_seconds())
        new_item["id"] = item.id
        new_item["in"] = False
        if DictAccounts.has_key(item.user2_id):
            new_item["in"] = True
        All.append(new_item)

    page = Req.GET.get('page', 1)

    PageObject = my_cached_paging("user_id_trans" + str(user_id), Trans, page, All)

    Dict["trans_list"] = PageObject.object_list
    Dict["paging"] = PageObject

    return tmpl_context(Req, t, Dict)