Ejemplo n.º 1
0
def Like_DisLikePost(Request):
    Form = LikeDisLikeForm(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)

    Post_Like_DisLike = LikesDisLikes.objects.filter(Post_id=Form.GetID(),
                                                     User_Email=Hashing.Hash_LikeDisLike(
                                                         Request.session["Email"]))
    if Post_Like_DisLike.exists():
        return JsonResponse(GF.Returns(0, 'You Already ' +
                                       ('Liked' if Post_Like_DisLike[0].Status == 0 else 'DisLiked')))

    LikeOrDisLike = LikesDisLikes(Post_id=Form.GetID(),
                                  User_Email=Hashing.Hash_LikeDisLike(Request.session["Email"]),
                                  Status=Form.GetType())
    LikeOrDisLike.save()

    if Request.session["Email"] != Result['Data']['Email']:
        Notification = Notifications(Type=(Form.GetType()+1),
                                     User_Email=Hashing.Hash_Notifications(
                                         Result['Data']['Email']),
                                     Message=Hashing.Hash_Notifications(
                                         json.dumps({
                                             'Email': Request.session["Email"],
                                             'PostID': Form.GetID()
                                         })
                                     ))
        Notification.save()
    return JsonResponse(GF.Returns(1, 'Done'))
Ejemplo n.º 2
0
def MakeArticle_POSTResponse(Request, Form):
    Post = Posts(User_Email=Hashing.Hash_Articles(Request.session["Email"]),
                 ArticleTitle=Hashing.Hash_Articles(Form.GetTitle()),
                 Article=Hashing.Hash_Articles(Form.GetArticle()),
                 Deleted=0,
                 Tags=Hashing.Hash_Articles(Form.GetTags()))
    Post.save()
    Request.session["Articles_Number"] += 1
    return HttpResponseRedirect(init.MakeArticle + '?Done')
Ejemplo n.º 3
0
def Settings_Password_CheckData(Request, Form):
    if not Users.objects.filter(Email=Hashing.Hash_Users(Request.session["Email"]),
                                Password=Hashing.Hash_Users(Form.GetOldPassword())).exists():
        return Settings_Render(Request, 'Password', 'WrongPassword')

    User = Users.objects.filter(Email=Hashing.Hash_Users(Request.session["Email"]))[0]
    User.Password = Hashing.Hash_Users(Form.GetPassword())
    User.save()
    return HttpResponseRedirect(init.Settings + '/Password?Result=PasswordDone')
Ejemplo n.º 4
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.º 5
0
def GetUserArticlesNumber(User):
    Result = Hashing.GetAllFromHashing([{
        'Type': 'Users',
        'Data': User.Email,
        'Key': 'Email'
    }])
    if Result['Result'] == -1:
        return 'UnKnown'
    return Posts.objects.filter(User_Email=Hashing.Hash_Articles(
        Result['Data']['Email']),
                                Deleted=0).count()
Ejemplo n.º 6
0
def GetUserDisLikes(User):
    Result = Hashing.GetAllFromHashing([{
        'Type': 'Users',
        'Data': User.Email,
        'Key': 'Email'
    }])
    if Result['Result'] == -1:
        return '0'
    return LikesDisLikes.objects.filter(User_Email=Hashing.Hash_LikeDisLike(
        Result['Data']['Email']),
                                        Status=1).count()
Ejemplo n.º 7
0
def GetPosts(Request):
    Form = CheckPostsNumberForm(Request.POST)
    if not Form.isValid():
        return JsonResponse(GF.Returns(-1, 'Not Valid Number'))

    Options = '0'
    Articles = ''
    index = int(Form.GetNumber())
    Slice = slice(index, index + 5)

    if URL.REFERER_is_Set(Request):

        if URL.GetREFERER(Request) == init.Articles+ '/':
            Options = '0'
            Articles = Posts.objects.filter(Deleted=0)[Slice]

        elif URL.GetREFERER(Request) == init.MyProfile:
            Options = '1'
            Articles = Posts.objects.filter(User_Email=Hashing.Hash_Articles(
                Request.session["Email"]), Deleted=0)[Slice]
        else:
            Match = re.search(r'' + init.User + '(\d)+', URL.GetREFERER(Request))
            if not Match:
                return StatusPages.UnAuthurithedUserPage(Request, 'Un Authorized User')
            User = Users.objects.filter(id=Match.group(1))
            if not User.exists():
                return StatusPages.UnAuthurithedUserPage(Request, 'Un Authorized User')
            Result = Hashing.GetAllFromHashing([{
                'Type': 'Users', 'Data': User[0].Email, 'Key': 'Email'}])
            if Result['Result'] == -1:
                return GF.Returns(-1, 'Getting Data From Hashing', Result['Result']['Error'])

            Articles = Posts.objects.filter(User_Email=Hashing.Hash_Articles(
                Result['Data']['Email']), Deleted=0)[Slice]
            Options = '2'

    if not Articles.exists():
        return JsonResponse(GF.Returns(0, 'No Data'))

    Result = GF.Returns(1, {
        'Posts': {},
        'Count': 0
    })
    Count = 0

    for Article in Articles:
        Text = ASF.GetPost(Article, Options)
        if Text != '':
            Count += 1
            Result['Data']['Posts'][str(Count)] = Text

    Result['Data']['Count'] = Count
    return JsonResponse(Result)
Ejemplo n.º 8
0
def Filter_Comment(Comment):
    Result = Hashing.GetAllFromHashing([{
        'Type': 'Comments',
        'Data': Comment.User_Email,
        'Key': 'Email'
    }, {
        'Type': 'Comments',
        'Data': Comment.Comment,
        'Key': 'Comment'
    }, {
        'Type': 'Date',
        'Data': Comment.Date,
        'Key': 'Date'
    }, {
        'Type': '',
        'Data': Comment.id,
        'Key': 'ID'
    }])

    if Result['Result'] == -1:
        return Returns(-1, 'Searching For User', Result['Error'])

    User = Users.objects.filter(Email=Hashing.Hash_Users(
        Result['Data']['Email']),
                                Deleted='0',
                                Activate='1')
    if not User.exists():
        return Returns(0, 'Not Found')

    Filtered_Comment = Result['Data']

    Result = Hashing.GetAllFromHashing([{
        'Type': 'Users',
        'Data': User[0].Name,
        'Key': 'Name'
    }, {
        'Type': 'Users',
        'Data': User[0].Picture,
        'Key': 'Picture'
    }, {
        'Type': '',
        'Data': User[0].id,
        'Key': 'id'
    }])

    if Result['Result'] == -1:
        return Returns(-1, 'Getting User Name From Hashing')

    Filtered_Comment['Name'] = Result['Data']['Name']
    Filtered_Comment['Picture'] = Result['Data']['Picture']
    Filtered_Comment['id'] = Result['Data']['id']

    return Returns(1, Filtered_Comment)
def GetNotification(Notification):
    Result = Hashing.GetAllFromHashing([{
        'Type': 'Notifications',
        'Data': Notification.User_Email,
        'Key': 'Email'
    }, {
        'Type': '',
        'Data': Notification.Type,
        'Key': 'Type'
    }, {
        'Type': 'Notifications',
        'Data': Notification.Message,
        'Key': 'Message'
    }])

    if Result['Result'] == -1:
        return ''

    Data = json.loads(Result['Data']['Message'])
    User = Users.objects.filter(Email=Hashing.Hash_Users(Data['Email']),
                                Deleted=0)
    if not User.exists():
        User = ''
    else:
        Hash = Hashing.Get_Hashed_Users(User[0].Name)
        if Hash['Result'] == -1:
            User = ''
        else:
            User = Hash['Data']

    Post = Posts.objects.filter(id=Data['PostID'], Deleted=0)
    if not Post.exists():
        Title = ''
    else:
        Hash = Hashing.Get_Hashed_Articles(Post[0].ArticleTitle)
        if Hash['Result'] == -1:
            Title = ''
        else:
            Title = Hash['Data']

    User = Span(User, 'Green')
    Title = Span(Title, 'Green')
    if Result['Data']['Type'] == 1:
        Message = 'User : '******' Liked Your Post : ' + Title
    elif Result['Data']['Type'] == 2:
        Message = 'User : '******' DisLiked Your Post : ' + Title
    elif Result['Data']['Type'] == 3:
        Message = 'User : '******' Commented in Your Post : ' + Title
    else:
        Message = 'User : '******' Added New Tag in Your Post : ' + Title

    return Div(P(Message))
Ejemplo n.º 10
0
def UserProfile(Request, User_id):
    User = Users.objects.filter(id=User_id, Activate=1, Deleted=0)
    if not User.exists():
        return StatusPages.NotFoundPage(Request, 'User')

    Result = Hashing.GetAllFromHashing([{'Type': 'Users', 'Data': User[0].Email, 'Key': 'Email'}])
    if Result['Result'] == -1:
        return StatusPages.ErrorPage(Request, 'User')

    Articles = Posts.objects.filter(User_Email=Hashing.Hash_Articles(Result['Data']['Email']),
                                    Deleted=0)[:5]

    return UserProfile_Render(Request, User[0], Articles)
Ejemplo n.º 11
0
def GetUserName(User):
    Result = Hashing.GetAllFromHashing([{
        'Type': 'Users',
        'Data': User.Name,
        'Key': 'Name'
    }])
    return 'UnKnown' if Result['Result'] == -1 else Result['Data']['Name']
Ejemplo n.º 12
0
def Settings_NameResponse(Request):
    Form = CheckNameForm(Request.POST)
    if Form.isValid():
        if Users.objects.filter(Name=Hashing.Hash_Users(Form.GetName())).exists():
            return Settings_Render(Request, 'Name', 'ReservedName')
        return Settings_Name_SaveData(Request, Form)
    return Settings_Render(Request, 'Name')
Ejemplo n.º 13
0
def GetUserPicture(User):
    Result = Hashing.GetAllFromHashing([{
        'Type': 'Users',
        'Data': User.Picture,
        'Key': 'Picture'
    }])
    return OnlineUser if Result['Result'] == -1 else Result['Data']['Picture']
Ejemplo n.º 14
0
def MakeArticle(Request):
    if not GF.SESSION(Request):
        return StatusPages.UnAuthurithedUserPage(Request, 'Make Article')

    if Request.method == 'POST' and URL.REFERER_is_Set(Request):
        Form = MakeArticleForm(Request.POST)
        if Form.isValid() and URL.GetREFERER(Request) == init.MakeArticle:
            return MakeArticle_POSTResponse(Request, Form)

    Post = Posts.objects.filter(User_Email=Hashing.Hash_Articles(
        Request.session["Email"]),
                                Deleted=0).order_by('-id')[:1]
    if not Post.exists():
        Article_id = ''
    else:
        Article_id = Post[0].id

    if 'Done' in Request.GET:
        Result = {
            'id': Article_id,
            'GetButtonValue': 'Make New Article',
            'GetResult': 'Done',
            'GetPage': ''
        }
        return Render.MakeOrEditSuccess_Render(Request, 'Make Article', Result)

    return Render.__Render(Request, init.MakeArticle_Template, 'Make Article')
Ejemplo n.º 15
0
def Settings_Account(Request, Type):
    User = Users.objects.filter(Email=Hashing.Hash_Users(Request.session["Email"]))[0]
    User.Activate = '0' if Type == 1 else '1'
    User.save()
    if GF.Delete_Session(Request)['Result'] == -1:
        return StatusPages.ErrorPage(Request, 'Settings')
    return HttpResponseRedirect(init.Articles)
Ejemplo n.º 16
0
def GetMoreNotifications(Request):
    if not GF.SESSION(Request) or not URL.REFERER_is_Set(Request):
        return StatusPages.UnAuthurithedUserPage(Request, 'Un Authorized User')

    if URL.GetREFERER(Request) != init.Notifications:
        return StatusPages.UnAuthurithedUserPage(Request, 'Un Authorized User')

    Form = CheckPostsNumberForm(Request.POST)
    if not Form.isValid():
        return JsonResponse(GF.Returns(-1, 'Not Valid Number'))

    index = int(Form.GetNumber())
    Slice = slice(index, index + 7)
    The_Notifications = Notifications.objects.filter(User_Email=Hashing.Hash_Notifications(
        Request.session["Email"])).order_by('-id')[Slice]

    if not len(The_Notifications):
        return JsonResponse(GF.Returns(0, 'No Data'))

    Result = GF.Returns(1, {
        'Notifications': {},
        'Count': 0
    })
    Count = 0

    for Notification in The_Notifications:
        Text = GetTheWholeNotification(Notification)
        if Text != '':
            Count += 1
            Result['Data']['Notifications'][str(Count)] = Text

    Result['Data']['Count'] = Count
    return JsonResponse(Result)
def GetPost(Article, args='0'):
    Result = CheckUser(Article.User_Email)
    if Result['Result'] != 1:
        return ''

    Result = Hashing.GetAllFromHashing([{
        'Type': 'Articles',
        'Data': Article.ArticleTitle,
        'Key': 'Title'
    }, {
        'Type': 'Articles',
        'Data': Article.Article,
        'Key': 'Article'
    }, {
        'Type': 'Articles',
        'Data': Article.Tags,
        'Key': 'Tags'
    }, {
        'Type': 'Date',
        'Data': Article.Date,
        'Key': 'Date'
    }, {
        'Type': '',
        'Data': Result['Data']['Name'],
        'Key': 'Name'
    }, {
        'Type': '',
        'Data': Result['Data']['Picture'],
        'Key': 'Picture'
    }, {
        'Type': '',
        'Data': Result['Data']['ID'],
        'Key': 'ID'
    }])

    if Result['Result'] == -1:
        return ''

    Likes = LikesDisLikes.objects.filter(Post_id=Article.id, Status=0).count()
    DisLikes = LikesDisLikes.objects.filter(Post_id=Article.id,
                                            Status=1).count()
    CommentsCount = Comments.objects.filter(Post_id=Article.id).count()

    return Div(
        Div(
            Div(
                A(init.User + str(Result['Data']['ID']),
                  InputImage(init.OnlineUser))) + Div(
                      P(Strong('By ') + ' : ' + Result['Data']['Name']) +
                      P(Strong('Date ') + ' : ' + Result['Data']['Date'])) +
            GetOptions(str(Article.id), args), 'Article_Header') +
        P(Strong('Title : ') + Result['Data']['Title'], 'Article_Title') + P(
            Strong('Tags : ') + GetArticleTags(Result['Data']['Tags']),
            'Article_Tags') + Div(P(GetText(Result['Data']['Article'], 2))) +
        Div(A(init.Article + str(Article.id), 'The Link To Full Article'),
            'Article_Link') + Div(
                P(Span('Likes ') + str(Likes)) +
                P(Span('DisLikes ') + str(DisLikes)) +
                P(Span('Comments ') + str(CommentsCount)), 'Article_Statics'),
        'Article', 'Post' + str(Article.id))
Ejemplo n.º 18
0
def GetPostTitle(Article):
    Result = Hashing.GetAllFromHashing([{
        'Type': 'Articles',
        'Data': Article.ArticleTitle,
        'Key': 'Title'
    }])
    return 'UnKnown' if Result['Result'] == -1 else Result['Data']['Title']
Ejemplo n.º 19
0
def EditArticle(Request, Article_id):
    if not GF.SESSION(Request):
        return StatusPages.UnAuthurithedUserPage(Request, 'Edit Article')

    Post = Posts.objects.filter(User_Email=Hashing.Hash_Articles(
        Request.session["Email"]),
                                id=Article_id,
                                Deleted=0)
    if not Post.exists():
        return StatusPages.NotFoundPage(Request, 'Edit Article')

    if Request.method == 'POST' and URL.REFERER_is_Set(Request):
        Form = MakeArticleForm(Request.POST)
        if Form.isValid() and URL.GetREFERER(
                Request) == init.EditArticle + str(Post[0].id):
            return EditArticle_POSTResponse(Form, Article_id)

    Result = Hashing.GetAllFromHashing([{
        'Type': 'Articles',
        'Data': Post[0].Article,
        'Key': 'Post'
    }, {
        'Type': 'Articles',
        'Data': Post[0].ArticleTitle,
        'Key': 'Title'
    }, {
        'Type': 'Articles',
        'Data': Post[0].Tags,
        'Key': 'Tags'
    }])

    if Result['Result'] == -1:
        return StatusPages.ErrorPage(Request, 'Edit Article')

    if 'Edited' in Request.GET:
        Result = {
            'id': Article_id,
            'GetButtonValue': 'Edit This Article',
            'GetResult': 'Edited',
            'GetPage': ''
        }
        return Render.MakeOrEditSuccess_Render(Request, 'Edit Article', Result)

    return Render.EditArticle_Render(
        Request, 'Edited' if 'Edited' in Request.GET else '',
        Result['Data']['Title'], Result['Data']['Post'],
        Result['Data']['Tags'])
Ejemplo n.º 20
0
def GetArticlePost(Article):
    Result = Hashing.GetAllFromHashing([{
        'Type': 'Articles',
        'Data': Article.Article,
        'Key': 'Article'
    }])
    return P('Error in Getting Post') if Result['Result'] == -1 else GetText(
        Result['Data']['Article'])
Ejemplo n.º 21
0
def CheckEmail(Request):
    Form = CheckEmailForm(Request.POST)
    if Form.isValid() and URL.REFERER_is_Set(Request):
        if URL.GetREFERER(Request) == init.SignUP:
            if Users.objects.filter(Email=Hashing.Hash_Users(Form.GetEmail())).exists():
                return JsonResponse(GF.Returns('1'))
            return JsonResponse(GF.Returns('0'))
    return StatusPages.UnAuthurithedUserPage(Request, 'Un Authorized User')
Ejemplo n.º 22
0
def MyNotifications(Request):
    if not GF.SESSION(Request):
        return StatusPages.UnAuthurithedUserPage(Request, 'My Notifications')

    UserNotifications = Notifications.objects.filter(User_Email=Hashing.Hash_Notifications(
        Request.session["Email"]
    )).order_by('-id')[:7]
    return MyNotifications_Render(Request, UserNotifications)
Ejemplo n.º 23
0
def MyProfile(Request):
    if not GF.SESSION(Request):
        return StatusPages.UnAuthurithedUserPage(Request, 'My Profile')

    return __Render(Request, init.MyProfile_Template, 'My Profile',
                    A=Posts.objects.filter(User_Email=Hashing.Hash_Articles(
                        Request.session["Email"]),
                                    Deleted='0')[:5])
Ejemplo n.º 24
0
def DeletePost(Request):
    Form = CheckPostsNumberForm(Request.POST)
    if not Form.isValid() or not URL.REFERER_is_Set(Request) or not GF.SESSION(Request):
        return StatusPages.UnAuthurithedUserPage(Request, 'Un Authorized User')

    if URL.GetREFERER(Request) != init.MyProfile:
        return StatusPages.UnAuthurithedUserPage(Request, 'Un Authorized User')

    if not Posts.objects.filter(User_Email=Hashing.Hash_Articles(Request.session["Email"]),
                                Deleted=0, id=Form.GetNumber()).exists():
        return JsonResponse(GF.Returns(0, 'Post Not Found'))

    Posts.objects.filter(User_Email=Hashing.Hash_Articles(Request.session["Email"]),
                         id=Form.GetNumber()).update(Deleted=1)

    Request.session["Articles_Number"] -= 1
    return JsonResponse(GF.Returns(1, 'Deleted'))
Ejemplo n.º 25
0
def GetArticleTags(Article):

    Result = Hashing.GetAllFromHashing([{
        'Type': 'Articles',
        'Data': Article.Tags,
        'Key': 'Tags'
    }])
    return Span('No Tags') if Result['Result'] == -1 else GetTags(
        Result['Data']['Tags'])
def CheckUser(Email):
    Result = Hashing.GetAllFromHashing([{
        'Type': 'Articles',
        'Data': Email,
        'Key': 'Email'
    }])
    if Result['Result'] == -1:
        return Returns(-1, 'Searching For User', Result['Error'])

    User = Users.objects.filter(Email=Hashing.Hash_Users(
        Result['Data']['Email']),
                                Deleted='0',
                                Activate='1')
    if not User.exists():
        return Returns(0, 'Not Found')

    Result = Hashing.GetAllFromHashing([{
        'Type': 'Users',
        'Data': User[0].Name,
        'Key': 'Name'
    }, {
        'Type': 'Users',
        'Data': User[0].Picture,
        'Key': 'Picture'
    }, {
        'Type': '',
        'Data': User[0].id,
        'Key': 'ID'
    }, {
        'Type': '',
        'Data': Result['Data']['Email'],
        'Key': 'Email'
    }])

    if Result['Result'] == -1:
        return Returns(-1, 'Searching For User', Result['Error'])

    return Returns(1, Result['Data'])
Ejemplo n.º 27
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.º 28
0
def CheckPost(Request, Form):
    if not Form.isValid() or not GF.SESSION(Request) or not URL.REFERER_is_Set(Request):
        return GF.Returns(-1, 'Not Valid')

    if not URL.GetREFERER(Request) == init.Article + str(Form.GetID()):
        return GF.Returns(-1, 'Not Valid')

    Post = Posts.objects.filter(Deleted='0', id=Form.GetID())
    if not Post.exists():
        return GF.Returns(0, 'Post Not Found')

    if ASF.CheckUser(Post[0].User_Email)['Result'] != 1:
        return GF.Returns(0, 'Post Not Found')

    Result = Hashing.GetAllFromHashing([{'Type': 'Articles', 'Data': Post[0].User_Email,
                                         'Key': 'Email'}])
    if Result['Result'] == -1:
        return GF.Returns(-1, 'Searching For User', Result['Error'])

    return GF.Returns(1, Result['Data'])
def GetTheWholeNotification(Notification):
    Result = Hashing.GetAllFromHashing([{
        'Type': 'Notifications',
        'Data': Notification.User_Email,
        'Key': 'Email'
    }, {
        'Type': '',
        'Data': Notification.Type,
        'Key': 'Type'
    }, {
        'Type': 'Notifications',
        'Data': Notification.Message,
        'Key': 'Message'
    }, {
        'Type': 'Date',
        'Data': Notification.Date,
        'Key': 'Date'
    }])

    if Result['Result'] == -1:
        return ''

    Data = json.loads(Result['Data']['Message'])
    Comment = Data['Comment'] if 'Comment' in Data else ''
    User = Users.objects.filter(Email=Hashing.Hash_Users(Data['Email']),
                                Deleted=0,
                                Activate=1)
    if not User.exists():
        UserName = ''
        UserPicture = init.OfflineUser
        UserID = ''
    else:
        Hash = Hashing.GetAllFromHashing([{
            'Type': 'Users',
            'Data': User[0].Name,
            'Key': 'Name'
        }, {
            'Type': '',
            'Data': User[0].id,
            'Key': 'ID'
        }, {
            'Type': 'Users',
            'Data': User[0].Picture,
            'Key': 'Picture'
        }])

        if Hash['Result'] == -1:
            UserName = ''
            UserPicture = init.OfflineUser
            UserID = ''
        else:
            UserName = Hash['Data']['Name']
            UserPicture = Hash['Data']['Picture']
            UserID = Hash['Data']['ID']

    Post = Posts.objects.filter(id=Data['PostID'], Deleted=0)
    if not Post.exists():
        Title = ''
    else:
        Hash = Hashing.Get_Hashed_Articles(Post[0].ArticleTitle)
        if Hash['Result'] == -1:
            Title = ''
        else:
            Title = Hash['Data']

    if Notification.See == 0:
        Class = 'Notification DidNotSeeNotification'
    else:
        Class = 'Notification'

    from Register.models import Notifications
    Notifications.objects.filter(id=Notification.id).update(See=1)

    Title = Strong(Title)
    if Result['Data']['Type'] == 1:
        Message = 'This User Liked Your Post : ' + Title
    elif Result['Data']['Type'] == 2:
        Message = 'This User DisLiked Your Post : ' + Title
    elif Result['Data']['Type'] == 3:
        Message = 'This User Commented in Your Post : ' + Title
    else:
        Message = 'This User Added New Tag To Your Post : ' + Title

    return Div(
        Div(
            A(init.User + str(UserID), InputImage(UserPicture)) + Div(
                P(Strong('By : ') + UserName) +
                P(Strong('Date : ') + Result['Data']['Date']))) + Div(
                    P(Message) +
                    A(GetLink(Data['PostID'], Result['Data']['Type'], Comment),
                      'The Link For Article')), Class)
Ejemplo n.º 30
0
def GetDisLikes(User_Email):
    return LikesDisLikes.objects.filter(
        User_Email=Hashing.Hash_LikeDisLike(User_Email), Status=1).count()