Exemplo n.º 1
0
def teamInfo(request, team_id):
    league_id = 1
    team = FootballTeam.objects.filter(id=team_id)
    if team:
        teamInfo = team[0]
    else:
        raise Http404
    teamInfoToShow = {}
    teamInfoToShow['name'] = teamInfo.name
    teamInfoToShow['info'] = teamInfo.info
    teamInfoToShow['date_founded'] = teamInfo.date_founded
    teamInfoToShow['league'] = teamInfo.league
    teamInfoToShow['stadium'] = teamInfo.stadium
    teamInfoToShow['manager'] = teamInfo.manager
    teamInfoToShow['team_logo'] = teamInfo.team_logo
    league_id = teamInfo.league.id
    season_query = DomesticSeason.objects.filter(league=teamInfo.league).filter(year=getLeagueYear())
    season = DomesticSeason
    if season_query:
        season = season_query[0]
    matchesFromTheSeason = DomesticSeasonMatch.objects.filter(season=season).order_by('week')
    passedMatches = []
    upComingMatches = []
    for match in matchesFromTheSeason:
        if match.homeTeam == teamInfo or match.awayTeam == teamInfo:
            if match.isFinished:
                passedMatches.append(match)
            else:
                upComingMatches.append(match)
    teamInfoToShow['passedMatches'] = passedMatches[:5]
    teamInfoToShow['upComingMatches'] = upComingMatches[:5]
    return render(request, 'statistics/teamInfo.html', {'navigationBar': getNavigationBar(), 'side_bar': getStatisticsSideBar(league_id), 'teamInfoToShow': teamInfoToShow})
Exemplo n.º 2
0
def sub_category(request, category_id, subcategory_id):
    main_category = SportNewsMainCategory.objects.filter(id=category_id)
    sub_category = SportNewsCategory.objects.filter(
        mainCategory=main_category).filter(id=subcategory_id)
    sub_category_name = ''
    if sub_category:
        sub_category_name = sub_category[0].name
    sub_category_news = SportNews.objects.filter(
        category=sub_category).order_by('-created_at')
    news_to_show = []
    for news in sub_category_news:
        newsItem = []
        newsItem.append(news.id)
        newsItem.append(news.photo)
        newsItem.append(news.title)
        news_to_show.append(newsItem)
    return render(request,
                  'main/subCategory.html', {
                      'user_info': getUseInfo(request),
                      'navigationBar': getNavigationBar(),
                      'side_bar': getSideBar(int(category_id)),
                      'sub_category_name': sub_category_name,
                      'news_to_show': news_to_show,
                  },
                  context_instance=RequestContext(request))
Exemplo n.º 3
0
def league(request, league_id):
    return render(
        request, 'statistics/league.html', {
            'navigationBar': getNavigationBar(),
            'side_bar': getStatisticsSideBar(league_id),
            'teamsInfo': getLeagueRanking(getLeagueYear(), league_id),
        })
Exemplo n.º 4
0
def info(request):
    return render(request,
                  'main/info.html', {
                      'user_info': getUseInfo(request),
                      'navigationBar': getNavigationBar(),
                      'side_bar': getSideBar(),
                  },
                  context_instance=RequestContext(request))
Exemplo n.º 5
0
def manager_info(request, manager_id):
    try:
        manager = FootballManager.objects.get(pk=manager_id)
    except FootballStadium.DoesNotExist:
        raise Http404
    return render(request, 'statistics/manager_info.html', {'navigationBar': getNavigationBar(), 'side_bar': getStatisticsSideBar(-1), 'manager': manager,})

#def ranking(request):
#    return HttpResponse("Ranking")
Exemplo n.º 6
0
def forgot_password(request):
    signUpErrors = {}
    if request.method == 'POST':
        if 'username' in request.POST and 'email' in request.POST:
            userQuery = User.objects.filter(username=request.POST['username'])
            if userQuery:
                user = userQuery[0]
                if user.email == request.POST['email']:
                    email_subject = 'Forgotten password for spirtal.py'
                    email_message = 'You requested from us to send you your password. Password:'******'*****@*****.**'
                    mail_to = []
                    mail_to.append(user.email)
                    send_mail(email_subject, email_message, email_from,
                              mail_to)
                    return HttpResponseRedirect('/accounts/login/')
                else:
                    signUpErrors['email'] = 'Email missmatched'
                    return render(
                        request, 'main/forgotten_pass.html', {
                            'signUpErrors': signUpErrors,
                            'user_info': getUseInfo(request),
                            'navigationBar': getNavigationBar(),
                            'side_bar': getSideBar(),
                        })
            else:
                signUpErrors['username'] = '******'
                return render(
                    request, 'main/forgotten_pass.html', {
                        'signUpErrors': signUpErrors,
                        'user_info': getUseInfo(request),
                        'navigationBar': getNavigationBar(),
                        'side_bar': getSideBar(),
                    })
    else:
        return render(request,
                      'main/forgotten_pass.html', {
                          'signUpErrors': signUpErrors,
                          'user_info': getUseInfo(request),
                          'navigationBar': getNavigationBar(),
                          'side_bar': getSideBar(),
                      },
                      context_instance=RequestContext(request))
Exemplo n.º 7
0
def stadium_info(request, stadium_id):
    try:
        stadium = FootballStadium.objects.get(pk=stadium_id)
    except FootballStadium.DoesNotExist:
        raise Http404
    return render(
        request, 'statistics/stadium_info.html', {
            'navigationBar': getNavigationBar(),
            'side_bar': getStatisticsSideBar(-1),
            'stadium': stadium,
        })
Exemplo n.º 8
0
def login_view(request):
    signUpErrors = {}
    if request.method == 'POST':
        username = request.POST['username']
        password = request.POST['password']
        user = authenticate(username=username, password=password)
        fromPath = request.POST['fromPath']
        fromPath = fromPath[:-1]
        if user is not None:
            if user.is_active:
                login(request, user)
                return HttpResponseRedirect(fromPath)
            else:
                signUpErrors['username'] = '******'
                return render(
                    request, 'main/login.html', {
                        'signUpErrors': signUpErrors,
                        'user_info': getUseInfo(request),
                        'navigationBar': getNavigationBar(),
                        'side_bar': getSideBar(),
                    })
        else:
            signUpErrors[
                'username'] = '******'
            return render(
                request, 'main/login.html', {
                    'signUpErrors': signUpErrors,
                    'user_info': getUseInfo(request),
                    'navigationBar': getNavigationBar(),
                    'side_bar': getSideBar(),
                })
    else:
        return render(
            request, 'main/login.html', {
                'signUpErrors': signUpErrors,
                'user_info': getUseInfo(request),
                'navigationBar': getNavigationBar(),
                'side_bar': getSideBar(),
            })
Exemplo n.º 9
0
def manager_info(request, manager_id):
    try:
        manager = FootballManager.objects.get(pk=manager_id)
    except FootballStadium.DoesNotExist:
        raise Http404
    return render(
        request, 'statistics/manager_info.html', {
            'navigationBar': getNavigationBar(),
            'side_bar': getStatisticsSideBar(-1),
            'manager': manager,
        })


#def ranking(request):
#    return HttpResponse("Ranking")
Exemplo n.º 10
0
def index(request):
    first_news = []
    first_news_list = SportNews.objects.filter(
        priority='NEWS_MAIN').order_by('-created_at')
    if len(first_news_list) > 0:
        news_info = {}
        news_info['title'] = first_news_list[0].title
        news_info['img'] = '/media/' + str(first_news_list[0].photo)
        first_news.append(first_news_list[0].id)
        first_news.append(news_info)
    main_news = []
    for news_prio in NEWS_PRIO:
        if news_prio[0] != 'NEWS_NORMAL' and news_prio[0] != 'NEWS_MAIN':
            main_news_list = SportNews.objects.filter(
                priority=news_prio[0]).order_by('-created_at')
            if len(main_news_list) > 0:
                news_info = {}
                news_info['title'] = main_news_list[0].title
                news_info['img'] = '/media/' + str(main_news_list[0].photo)
                news = []
                news.append(main_news_list[0].id)
                news.append(news_info)
                main_news.append(news)

    other_news_list = SportNews.objects.all().order_by('-created_at')[:20]
    other_news = []
    for other in other_news_list:
        news = []
        news.append(other.id)
        news.append(other.photo)
        news.append(other.title)
        isItemInMainNews = False
        for mainNewsItem in main_news:
            if mainNewsItem[0] == news[0]:
                isItemInMainNews = True
        if not isItemInMainNews and first_news and other.id != first_news[0]:
            other_news.append(news)

    return render(request,
                  'main/index.html', {
                      'user_info': getUseInfo(request),
                      'navigationBar': getNavigationBar(),
                      'side_bar': getSideBar(),
                      'first_news': first_news,
                      'main_news': main_news,
                      'other_news': other_news,
                  },
                  context_instance=RequestContext(request))
Exemplo n.º 11
0
def teamInfo(request, team_id):
    league_id = 1
    team = FootballTeam.objects.filter(id=team_id)
    if team:
        teamInfo = team[0]
    else:
        raise Http404
    teamInfoToShow = {}
    teamInfoToShow['name'] = teamInfo.name
    teamInfoToShow['info'] = teamInfo.info
    teamInfoToShow['date_founded'] = teamInfo.date_founded
    teamInfoToShow['league'] = teamInfo.league
    teamInfoToShow['stadium'] = teamInfo.stadium
    teamInfoToShow['manager'] = teamInfo.manager
    teamInfoToShow['team_logo'] = teamInfo.team_logo
    league_id = teamInfo.league.id
    season_query = DomesticSeason.objects.filter(
        league=teamInfo.league).filter(year=getLeagueYear())
    season = DomesticSeason
    if season_query:
        season = season_query[0]
    matchesFromTheSeason = DomesticSeasonMatch.objects.filter(
        season=season).order_by('week')
    passedMatches = []
    upComingMatches = []
    for match in matchesFromTheSeason:
        if match.homeTeam == teamInfo or match.awayTeam == teamInfo:
            if match.isFinished:
                passedMatches.append(match)
            else:
                upComingMatches.append(match)
    teamInfoToShow['passedMatches'] = passedMatches[:5]
    teamInfoToShow['upComingMatches'] = upComingMatches[:5]
    return render(
        request, 'statistics/teamInfo.html', {
            'navigationBar': getNavigationBar(),
            'side_bar': getStatisticsSideBar(league_id),
            'teamInfoToShow': teamInfoToShow
        })
Exemplo n.º 12
0
def news(request, news_id):
    comment_to_answer_id = '-1'
    if request.method == 'POST' and 'comment_to_answer_id' in request.POST:
        comment_to_answer_id = request.POST['comment_to_answer_id']
        comment_to_answer_id = comment_to_answer_id[:-1]
    try:
        news = SportNews.objects.get(pk=news_id)
    except SportNews.DoesNotExist:
        raise Http404
    photoUrl = '/media/' + str(news.photo)
    category_id = news.category.mainCategory.id
    comments = SportNewsComment.objects.filter(
        news=news).order_by('-created_at')
    comments_to_show = []
    for comment in comments:
        comment_to_show = {}
        comment_to_show['id'] = comment.id
        comment_to_show['created_at'] = comment.created_at
        comment_to_show['comment_number'] = comment.comment_number
        comment_to_show['user_username'] = comment.user.username
        comment_to_show['user_first_name'] = comment.user.first_name
        comment_to_show['user_last_name'] = comment.user.last_name
        comment_to_show['title'] = comment.title
        comment_to_show['text'] = comment.text
        comment_to_show['root_comment'] = comment.root_comment
        comments_to_show.append(comment_to_show)
    return render(request,
                  'main/news.html', {
                      'user_info': getUseInfo(request),
                      'navigationBar': getNavigationBar(),
                      'side_bar': getSideBar(category_id),
                      'news_id': news_id,
                      'news_title': news.title,
                      'news_text': news.text,
                      'photo': photoUrl,
                      'comments_to_show': comments_to_show,
                      'comment_to_answer_id': int(comment_to_answer_id)
                  },
                  context_instance=RequestContext(request))
Exemplo n.º 13
0
def search_news(request):
    search_word = ''
    if request.method == 'GET':
        search_word = request.GET['search_text']
    elif request.method == 'POST':
        search_word = request.POST['search_text']
    searched_news = SportNews.objects.filter(
        Q(title__icontains=search_word) | Q(text__icontains=search_word)
        | Q(category__name__icontains=search_word))
    news_to_show = []
    for news in searched_news:
        newsItem = []
        newsItem.append(news.id)
        newsItem.append(news.photo)
        newsItem.append(news.title)
        news_to_show.append(newsItem)
    return render(
        request, 'main/search_news.html', {
            'search_word': search_word,
            'user_info': getUseInfo(request),
            'navigationBar': getNavigationBar(),
            'side_bar': getSideBar(int()),
            'news_to_show': news_to_show,
        })
Exemplo n.º 14
0
def create_account(request):
    signUpErrors = {}
    if request.method == 'POST':
        signUpErrors = getEmptyFieldsSignUpErrors(request)
        username = request.POST['username_create']
        password = request.POST['password_create']
        confirm_password = request.POST['confirm_password']
        first_name = request.POST['first_name']
        last_name = request.POST['last_name']
        email = request.POST['email']
        if username != '':
            if checkIfUserNameAlreadyExists(username):
                signUpErrors['username_create'] = 'User name already exists'
                return render(
                    request, 'main/signup.html', {
                        'user_info': getUseInfo(request),
                        'navigationBar': getNavigationBar(),
                        'signUpErrors': signUpErrors,
                    })
            if not checkIfPasswordIsValid(password):
                signUpErrors[
                    'password_create'] = 'Your password did not meet the limitations.'
                return render(
                    request, 'main/signup.html', {
                        'user_info': getUseInfo(request),
                        'navigationBar': getNavigationBar(),
                        'signUpErrors': signUpErrors,
                    })
            if not checkIfPasswordMatch(password, confirm_password):
                signUpErrors[
                    'confirm_password'] = '******'
                return render(
                    request, 'main/signup.html', {
                        'user_info': getUseInfo(request),
                        'navigationBar': getNavigationBar(),
                        'signUpErrors': signUpErrors,
                    })
            if first_name == '':
                return render(
                    request, 'main/signup.html', {
                        'user_info': getUseInfo(request),
                        'navigationBar': getNavigationBar(),
                        'signUpErrors': signUpErrors,
                    })
            if last_name == '':
                return render(
                    request, 'main/signup.html', {
                        'user_info': getUseInfo(request),
                        'navigationBar': getNavigationBar(),
                        'signUpErrors': signUpErrors,
                    })
            if not checkIfEmailisValid(email):
                signUpErrors['email'] = 'The email is not valid'
                return render(
                    request, 'main/signup.html', {
                        'user_info': getUseInfo(request),
                        'navigationBar': getNavigationBar(),
                        'signUpErrors': signUpErrors,
                    })
            new_user = User()
            new_user.username = username
            new_user.set_password(password)
            new_user.first_name = first_name
            new_user.last_name = last_name
            new_user.email = email
            new_user.save()
            authenticated_user = authenticate(username=username,
                                              password=password)
            login(request, authenticated_user)
            return HttpResponseRedirect('/')
    else:
        return render(
            request, 'main/signup.html', {
                'user_info': getUseInfo(request),
                'navigationBar': getNavigationBar(),
                'signUpErrors': signUpErrors,
            })
Exemplo n.º 15
0
def index(request):
    first_news = []
    first_news_list = SportNews.objects.filter(priority='NEWS_MAIN').order_by('-created_at')
    if len(first_news_list) > 0:
        news_info = {}
        news_info['title'] = first_news_list[0].title
        news_info['img'] = '/media/' + str(first_news_list[0].photo)
        first_news.append(first_news_list[0].id)
        first_news.append(news_info)
    main_news = []
    for news_prio in NEWS_PRIO:
        if news_prio[0] != 'NEWS_NORMAL' and news_prio[0] != 'NEWS_MAIN':
            main_news_list = SportNews.objects.filter(priority=news_prio[0]).order_by('-created_at')
            if len(main_news_list) > 0:
                news_info = {}
                news_info['title'] = main_news_list[0].title
                news_info['img'] = '/media/' + str(main_news_list[0].photo)
                news = []
                news.append(main_news_list[0].id)
                news.append(news_info)
                main_news.append(news)
    
    other_news_list = SportNews.objects.all().order_by('-created_at')[:20]
    other_news = []
    for other in other_news_list:
        news = []
        news.append(other.id)
        news.append(other.photo)
        news.append(other.title)
        isItemInMainNews = False
        for mainNewsItem in main_news:
            if mainNewsItem[0] == news[0]:
                isItemInMainNews = True
        if not isItemInMainNews and first_news and other.id != first_news[0]:
            other_news.append(news)
            
    return render(request,
                  'main/index.html', {'user_info': getUseInfo(request), 'navigationBar': getNavigationBar(),'side_bar': getSideBar(), 'first_news': first_news, 'main_news': main_news, 'other_news': other_news,},
                  context_instance=RequestContext(request)
                  )
Exemplo n.º 16
0
def search_news(request):
    search_word = ''
    if request.method == 'GET':
        search_word = request.GET['search_text']
    elif request.method == 'POST':
        search_word = request.POST['search_text']
    searched_news = SportNews.objects.filter(Q(title__icontains=search_word) | Q(text__icontains=search_word) | Q(category__name__icontains=search_word))
    news_to_show = []
    for news in searched_news:
        newsItem = []
        newsItem.append(news.id)
        newsItem.append(news.photo)
        newsItem.append(news.title)
        news_to_show.append(newsItem)
    return render(request, 'main/search_news.html', {'search_word': search_word,'user_info': getUseInfo(request), 'navigationBar': getNavigationBar(),'side_bar': getSideBar(int()), 'news_to_show': news_to_show,})
Exemplo n.º 17
0
def info(request):
    return render(request, 'main/info.html', {'user_info': getUseInfo(request), 'navigationBar': getNavigationBar(),'side_bar': getSideBar(),},
                  context_instance=RequestContext(request))
Exemplo n.º 18
0
def stadium_info(request, stadium_id):
    try:
        stadium = FootballStadium.objects.get(pk=stadium_id)
    except FootballStadium.DoesNotExist:
        raise Http404
    return render(request, 'statistics/stadium_info.html', {'navigationBar': getNavigationBar(), 'side_bar': getStatisticsSideBar(-1), 'stadium': stadium,})
Exemplo n.º 19
0
def forgot_password(request):
    signUpErrors = {}
    if request.method == 'POST':
        if 'username' in request.POST and 'email' in request.POST:
            userQuery = User.objects.filter(username=request.POST['username'])
            if userQuery:
                user = userQuery[0]
                if user.email == request.POST['email']:
                    email_subject = 'Forgotten password for spirtal.py'
                    email_message = 'You requested from us to send you your password. Password:'******'*****@*****.**'
                    mail_to = []
                    mail_to.append(user.email)
                    send_mail(email_subject, email_message, email_from, mail_to)
                    return HttpResponseRedirect('/accounts/login/')
                else:
                    signUpErrors['email'] = 'Email missmatched'
                    return render(request, 'main/forgotten_pass.html', {'signUpErrors': signUpErrors, 'user_info': getUseInfo(request), 'navigationBar': getNavigationBar(),'side_bar': getSideBar(),})
            else:
                signUpErrors['username'] = '******'
                return render(request, 'main/forgotten_pass.html', {'signUpErrors': signUpErrors, 'user_info': getUseInfo(request), 'navigationBar': getNavigationBar(),'side_bar': getSideBar(),})
    else:
        return render(request, 'main/forgotten_pass.html', {'signUpErrors': signUpErrors, 'user_info': getUseInfo(request), 'navigationBar': getNavigationBar(),'side_bar': getSideBar(),},
                  context_instance=RequestContext(request))
Exemplo n.º 20
0
def create_account(request):
    signUpErrors = {}
    if request.method == 'POST':
        signUpErrors = getEmptyFieldsSignUpErrors(request)
        username = request.POST['username_create']
        password = request.POST['password_create']
        confirm_password = request.POST['confirm_password']
        first_name = request.POST['first_name']
        last_name = request.POST['last_name']
        email = request.POST['email']
        if username != '':
            if checkIfUserNameAlreadyExists(username):
                signUpErrors['username_create'] = 'User name already exists'
                return render(request, 'main/signup.html', {'user_info': getUseInfo(request), 'navigationBar': getNavigationBar(), 'signUpErrors': signUpErrors,})
            if not checkIfPasswordIsValid(password):
                signUpErrors['password_create'] = 'Your password did not meet the limitations.'
                return render(request, 'main/signup.html', {'user_info': getUseInfo(request), 'navigationBar': getNavigationBar(), 'signUpErrors': signUpErrors,})
            if not checkIfPasswordMatch(password, confirm_password):
                signUpErrors['confirm_password'] = '******'
                return render(request, 'main/signup.html', {'user_info': getUseInfo(request), 'navigationBar': getNavigationBar(), 'signUpErrors': signUpErrors,})
            if first_name == '':
                return render(request, 'main/signup.html', {'user_info': getUseInfo(request), 'navigationBar': getNavigationBar(), 'signUpErrors': signUpErrors,})
            if last_name == '':
                return render(request, 'main/signup.html', {'user_info': getUseInfo(request), 'navigationBar': getNavigationBar(), 'signUpErrors': signUpErrors,})
            if not checkIfEmailisValid(email):
                signUpErrors['email'] = 'The email is not valid'
                return render(request, 'main/signup.html', {'user_info': getUseInfo(request), 'navigationBar': getNavigationBar(), 'signUpErrors': signUpErrors,})
            new_user = User()
            new_user.username = username
            new_user.set_password(password)
            new_user.first_name = first_name
            new_user.last_name = last_name
            new_user.email = email
            new_user.save()
            authenticated_user = authenticate(username=username, password=password)
            login(request, authenticated_user)
            return HttpResponseRedirect('/')
    else:
        return render(request, 'main/signup.html', {'user_info': getUseInfo(request), 'navigationBar': getNavigationBar(), 'signUpErrors': signUpErrors,})
Exemplo n.º 21
0
def sub_category(request, category_id, subcategory_id):
    main_category = SportNewsMainCategory.objects.filter(id=category_id)
    sub_category = SportNewsCategory.objects.filter(mainCategory=main_category).filter(id=subcategory_id)
    sub_category_name = ''
    if sub_category:
        sub_category_name = sub_category[0].name
    sub_category_news = SportNews.objects.filter(category=sub_category).order_by('-created_at')
    news_to_show = []
    for news in sub_category_news:
        newsItem = []
        newsItem.append(news.id)
        newsItem.append(news.photo)
        newsItem.append(news.title)
        news_to_show.append(newsItem)
    return render(request,
                  'main/subCategory.html', {'user_info': getUseInfo(request), 'navigationBar': getNavigationBar(),'side_bar': getSideBar(int(category_id)), 'sub_category_name': sub_category_name, 'news_to_show': news_to_show,},
                  context_instance=RequestContext(request))
Exemplo n.º 22
0
def news(request, news_id):
    comment_to_answer_id = '-1'
    if request.method == 'POST' and 'comment_to_answer_id' in request.POST:
        comment_to_answer_id = request.POST['comment_to_answer_id']
        comment_to_answer_id = comment_to_answer_id[:-1]
    try:
        news = SportNews.objects.get(pk=news_id)
    except SportNews.DoesNotExist:
        raise Http404
    photoUrl = '/media/' + str(news.photo)
    category_id = news.category.mainCategory.id
    comments = SportNewsComment.objects.filter(news=news).order_by('-created_at')
    comments_to_show = []
    for comment in comments:
        comment_to_show = {}
        comment_to_show['id'] = comment.id
        comment_to_show['created_at'] = comment.created_at
        comment_to_show['comment_number'] = comment.comment_number
        comment_to_show['user_username'] = comment.user.username
        comment_to_show['user_first_name'] = comment.user.first_name
        comment_to_show['user_last_name'] = comment.user.last_name
        comment_to_show['title'] = comment.title
        comment_to_show['text'] = comment.text
        comment_to_show['root_comment'] = comment.root_comment
        comments_to_show.append(comment_to_show)
    return render(request,
                  'main/news.html', {'user_info': getUseInfo(request), 'navigationBar': getNavigationBar(),'side_bar': getSideBar(category_id), 'news_id': news_id, 'news_title': news.title, 'news_text': news.text, 'photo': photoUrl, 'comments_to_show': comments_to_show, 'comment_to_answer_id': int(comment_to_answer_id)},
                  context_instance=RequestContext(request))
Exemplo n.º 23
0
def league(request, league_id):
    return render(request, 'statistics/league.html', {'navigationBar': getNavigationBar(),'side_bar': getStatisticsSideBar(league_id), 'teamsInfo': getLeagueRanking(getLeagueYear(), league_id),})
Exemplo n.º 24
0
def login_view(request):
    signUpErrors = {}
    if request.method == 'POST':
        username = request.POST['username']
        password = request.POST['password']
        user = authenticate(username=username, password=password)
        fromPath = request.POST['fromPath']
        fromPath = fromPath[:-1]
        if user is not None:
            if user.is_active:
                login(request, user)
                return HttpResponseRedirect(fromPath)
            else:
                signUpErrors['username'] = '******'
                return render(request, 'main/login.html', {'signUpErrors': signUpErrors, 'user_info': getUseInfo(request), 'navigationBar': getNavigationBar(),'side_bar': getSideBar(),})
        else:
            signUpErrors['username'] = '******'
            return render(request, 'main/login.html', {'signUpErrors': signUpErrors, 'user_info': getUseInfo(request), 'navigationBar': getNavigationBar(),'side_bar': getSideBar(),})
    else:
        return render(request, 'main/login.html', {'signUpErrors': signUpErrors, 'user_info': getUseInfo(request), 'navigationBar': getNavigationBar(),'side_bar': getSideBar(),})