Ejemplo n.º 1
0
def GetUserComments(User):
    Result = Hashing.GetAllFromHashing([{
        'Type': 'Users',
        'Data': User.Email,
        'Key': 'Email'
    }])
    if Result['Result'] == -1:
        return '0'
    return Comments.objects.filter(
        User_Email=Hashing.Hash_Comments(Result['Data']['Email'])).count()
Ejemplo n.º 2
0
def MakeComment(Request):
    Form = MakeCommentForm(Request.POST)
    Result = CheckPost(Request, Form)

    if Result['Result'] != 1:
        if Result['Data'] == 'Not Valid':
            return StatusPages.UnAuthurithedUserPage(Request, 'Un Authorized User')
        return JsonResponse(Result)

    Comment = Comments(Post_id=Form.GetID(),
                       User_Email=Hashing.Hash_Comments(Request.session["Email"]),
                       Comment=Hashing.Hash_Comments(Form.GetComment()))
    Comment.save()
    Comment = Comments.objects.filter().order_by('-id')[:1]
    if not Comment.exists():
        Comment = ''
    else:
        Comment = Comment[0].id

    if Request.session["Email"] != Result['Data']['Email']:
        Notification = Notifications(Type=3,
                                     User_Email=Hashing.Hash_Notifications(
                                         Result['Data']['Email']),
                                     Message=Hashing.Hash_Notifications(
                                         json.dumps({
                                             'Email': Request.session["Email"],
                                             'PostID': Form.GetID(),
                                             'Comment': Comment
                                         })
                                     ))
        Notification.save()

    return JsonResponse(GF.Returns(1, Div(
        Div(A(init.User+str(Request.session["ID"]), InputImage(Request.session["Picture"])) +
            Div(P('By : '+Request.session["Name"]) +
                P('Date : '+str(datetime.datetime.now())))) +
        Div(P(GetText(Form.GetComment())), 'Comment_Text')
        , 'Comments')))
Ejemplo n.º 3
0
def GetComments(User_Email):
    return Comments.objects.filter(
        User_Email=Hashing.Hash_Comments(User_Email)).count()