Exemplo n.º 1
0
def login(request):
    currentIP, totalVisit = VisitStatistic.change_info(request)
    if request.session.get('is_login', None):
        return redirect("/")

    if request.method == "POST":
        login_form = UserForm(request.POST)
        message = _('Please re-check the contents filled')
        if login_form.is_valid():
            username = login_form.cleaned_data['username']
            password = login_form.cleaned_data['password']
            try:
                user = models.User.objects.get(name=username)
                if not user.has_confirmed:
                    message = _("Please wait for the approval of website`s manager")
                    return render(request, 'UserManagement/login.html',
                                  {'message': message, 'login_form': login_form, "currentIP": currentIP,
                                   'total_visit': totalVisit})
                if user.password == Toolbox.hash_code(password):
                    request.session['is_login'] = True
                    request.session['user_id'] = user.id
                    request.session['user_name'] = user.name
                    return redirect('/DBCPOnline/Preparation', {"currentIP": currentIP,
                                                                'total_visit': totalVisit})
                else:
                    message = _("Incorrect username or password!")
            except:
                message = _("Incorrect username or password!")
        return render(request, 'UserManagement/login.html',
                      {"message": message, 'login_form': login_form, "currentIP": currentIP,
                       'total_visit': totalVisit})
    login_form = UserForm()
    return render(request, 'UserManagement/login.html', {'login_form': login_form, "currentIP": currentIP,
                                                         'total_visit': totalVisit})
Exemplo n.º 2
0
def Preprocessing(request):
    if not request.session.get('is_login', None):
        return render(request, 'DBCPOnline/Preprocessing.html')
    context = {
        'dynamicWindowNumber': range(1, 126),
    }
    currentIP, totalVisit = VisitStatistic.change_info(request)
    totalRecords, completeRecords, runningRecords, FailedRecords, totalServer, idleServer, LiLei, PengLong, WangYipei, Test, waitingRecords, Daikexuan, Jiangzhuolin = getDetailRecords()
    schedulerStatus = getschedulerStatus(type='CorrelationConnectivity')
    authorized = checkAuthorization(userid=request.session['user_id'])
    return render(request, 'DBCPOnline/Preprocessing.html', {'context': context,
                                                             "currentIP": currentIP,
                                                             'total_visit': totalVisit,
                                                             'totalRecords': totalRecords,
                                                             'runningRecords': runningRecords,
                                                             'completeRecords': completeRecords,
                                                             'runningServer': totalServer - idleServer,
                                                             'waitingRecords': waitingRecords,
                                                             'idleServer': idleServer,
                                                             'deadServer': totalServer - idleServer - runningRecords,
                                                             'LiLei': LiLei,
                                                             'Aaron08131': PengLong,
                                                             'WangYipei': WangYipei,
                                                             'Daikexuan': Daikexuan,
                                                             'Jiangzhuolin': Jiangzhuolin,
                                                             'schedulerStatus': schedulerStatus,
                                                             'Test': Test,
                                                             'authorized': authorized,
                                                             'FailedRecords': FailedRecords})
Exemplo n.º 3
0
def Preparation(request):
    if not request.session.get('is_login', None):
        return render(request, 'DBCPOnline/Preparation.html')
    authorized = checkAuthorization(userid=request.session['user_id'])
    currentIP, totalVisit = VisitStatistic.change_info(request)
    return render(request, 'DBCPOnline/Preparation.html', {"currentIP": currentIP,
                                                           'authorized': authorized,
                                                           'total_visit': totalVisit})
Exemplo n.º 4
0
def register(request):
    currentIP, totalVisit = VisitStatistic.change_info(request)
    if request.session.get('is_login', None):
        return redirect("/index/")
    if request.method == "POST":

        register_form = RegisterForm(request.POST)
        message = _('Please re-check the contents filled')
        if register_form.is_valid():
            username = register_form.cleaned_data['username']
            password1 = register_form.cleaned_data['password1']
            password2 = register_form.cleaned_data['password2']
            email = register_form.cleaned_data['email']
            # sex = register_form.cleaned_data['sex']
            usage = register_form.cleaned_data['usage']
            affiliation = register_form.cleaned_data['affiliation']
            if password1 != password2:
                message = _("Passwords filled not match")
                return render(request, 'UserManagement/register.html',
                              {'message': message, 'register_form': register_form, "currentIP": currentIP,
                               'total_visit': totalVisit})
            else:
                same_name_user = models.User.objects.filter(name=username)
                if same_name_user:  # 用户名唯一
                    message = _('UserName existed !')
                    return render(request, 'UserManagement/register.html',
                                  {'message': message, 'register_form': register_form, "currentIP": currentIP,
                                   'total_visit': totalVisit})
                same_email_user = models.User.objects.filter(email=email)
                if same_email_user:  # 邮箱地址唯一
                    message = _('Email address occupied !')
                    return render(request, 'UserManagement/register.html',
                                  {'message': message, 'register_form': register_form, "currentIP": currentIP,
                                   'total_visit': totalVisit})

                # 当一切都OK的情况下,创建新用户

                new_user = models.User.objects.create()
                new_user.name = username
                new_user.password = Toolbox.hash_code(password1)
                new_user.email = email
                # new_user.sex = sex
                new_user.usage = usage
                new_user.affiliation = affiliation
                new_user.save()

                code = Toolbox.Make_ConfirmString(new_user)
                Toolbox.SendUserConfirmMail(new_user.name, email, code)

                return redirect('/UserManagement/login/',
                                {"currentIP": currentIP, 'total_visit': totalVisit})  # 自动跳转到登录页面
        return render(request, 'UserManagement/register.html',
                      {'message': message, 'register_form': register_form, "currentIP": currentIP,
                       'total_visit': totalVisit})
    register_form = RegisterForm()
    return render(request, 'UserManagement/register.html',
                  {'register_form': register_form, "currentIP": currentIP, 'total_visit': totalVisit})
Exemplo n.º 5
0
def Migration(request):
    if not request.session.get('is_login', None):
        return HttpResponse("Please Login in first")
    authorized = checkAuthorization(userid=request.session['user_id'])
    currentIP, totalVisit = VisitStatistic.change_info(request)
    totalRecords, completeRecords, runningRecords, FailedRecords, totalServer, idleServer, waitingRecords = getDetailKBCARecords()
    schedulerStatus = getschedulerStatus(type='CausalityConnectivity')
    return render(request, 'DBCPOnline/Migration.html', {
        "currentIP": currentIP,
        'total_visit': totalVisit,
        'authorized': authorized,
        'totalRecords': totalRecords,
        'runningRecords': runningRecords,
        'completeRecords': completeRecords,
        'runningServer': totalServer - idleServer,
        'waitingRecords': waitingRecords,
        'idleServer': idleServer,
        'deadServer': totalServer - idleServer - runningRecords,
        'schedulerStatus': schedulerStatus,
        'FailedRecords': FailedRecords})
Exemplo n.º 6
0
def Manage(request):
    if not request.session.get('is_login', None):
        return render(request, 'DBCPOnline/Manage.html')
    user = User.objects.get(id=request.session['user_id'])
    if user.name != '王博丞':
        return HttpResponse('无权限')
    currentIP, totalVisit = VisitStatistic.change_info(request)
    parcellation_schedulerStatus = getschedulerStatus(type='CorrelationConnectivity')
    causality_schedulerStatus = getschedulerStatus(type='CausalityConnectivity')
    parcellation_debug = getDebugInfo(type='CorrelationConnectivity')
    causality_debug = getDebugInfo(type='CausalityConnectivity')
    causalityLastRunTime = getTaskLastRunInfo(type='CausalityConnectivity')
    parcellationLastRunTime = getTaskLastRunInfo(type='CorrelationConnectivity')
    authorized = checkAuthorization(userid=request.session['user_id'])
    return render(request, 'DBCPOnline/Manage.html', {"currentIP": currentIP,
                                                      'parcellation_schedulerStatus': parcellation_schedulerStatus,
                                                      'causality_schedulerStatus': causality_schedulerStatus,
                                                      'parcellation_debug': parcellation_debug,
                                                      'causality_debug': causality_debug,
                                                      'parcellationLastRunTime': parcellationLastRunTime,
                                                      'causalityLastRunTime': causalityLastRunTime,
                                                      'authorized': authorized,
                                                      'total_visit': totalVisit})
Exemplo n.º 7
0
def homepage(request):
    currentIP, totalVisit = VisitStatistic.change_info(request)
    return render(request, 'homepage.html', {
        "currentIP": currentIP,
        'total_visit': totalVisit
    })
Exemplo n.º 8
0
def ContactUs(request):
    currentIP, totalVisit = VisitStatistic.change_info(request)
    return render(request, 'ContentManagement/ContactUs.html', {
        "currentIP": currentIP,
        'total_visit': totalVisit
    })
Exemplo n.º 9
0
def ProjectMember(request):
    currentIP, totalVisit = VisitStatistic.change_info(request)
    return render(request, 'ContentManagement/ProjectMember.html', {
        "currentIP": currentIP,
        'total_visit': totalVisit
    })
Exemplo n.º 10
0
def Usage(request):
    currentIP, totalVisit = VisitStatistic.change_info(request)
    return render(request, 'DBCPOnline/Usage.html', {"currentIP": currentIP,
                                                     'total_visit': totalVisit})
Exemplo n.º 11
0
def Multimodal(request):
    currentIP, totalVisit = VisitStatistic.change_info(request)
    return render(request, 'DBCPOnline/Multimodal.html', {"currentIP": currentIP,
                                                          'total_visit': totalVisit})
Exemplo n.º 12
0
def Hypothesis(request):
    currentIP, totalVisit = VisitStatistic.change_info(request)
    return render(request, 'DBCPOnline/Hypothesis.html', {"currentIP": currentIP,
                                                          'total_visit': totalVisit})
Exemplo n.º 13
0
def DeepLearning(request):
    currentIP, totalVisit = VisitStatistic.change_info(request)
    return render(request, 'DBCPOnline/DeepLearning.html', {"currentIP": currentIP,
                                                            'total_visit': totalVisit})
Exemplo n.º 14
0
def TopologicalAnalysis(request):
    currentIP, totalVisit = VisitStatistic.change_info(request)
    return render(request, 'DBCPOnline/TopologicalAnalysis.html', {"currentIP": currentIP,
                                                                   'total_visit': totalVisit})
Exemplo n.º 15
0
def Visualization(request):
    currentIP, totalVisit = VisitStatistic.change_info(request)
    return render(request, 'DBCPOnline/Visualization.html', {"currentIP": currentIP,
                                                             'total_visit': totalVisit})
Exemplo n.º 16
0
def userdetail(request):
    currentIP, totalVisit = VisitStatistic.change_info(request)
    if request.session.get('is_login', None):
        return render(request, 'UserManagement/userdetail.html', locals())
    return redirect("/", {"currentIP": currentIP, 'total_visit': totalVisit})