Beispiel #1
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')
Beispiel #2
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)
Beispiel #3
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')
Beispiel #4
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')
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))
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'])
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)
Beispiel #9
0
def Settings_Name_SaveData(Request, Form):
    User = Users.objects.filter(Email=Hashing.Hash_Users(Request.session["Email"]))[0]
    User.Name = Hashing.Hash_Users(Form.GetName())
    User.save()
    Request.session["Name"] = Form.GetName()
    return HttpResponseRedirect(init.Settings + '/Name?Result=NameDone')