Пример #1
0
def register_view(request):  
    pisettings_instance = globaldata.getclient()
    if pisettings_instance.enable_register != True:
        return HttpResponse("You are not be allowed to register") 
    form = PiRegisterForm(request.POST or None)
    if form.is_valid():
        first_name=form.cleaned_data['first_name']
        last_name=form.cleaned_data['last_name']      
        email = form.cleaned_data['email'] 
        password=form.cleaned_data['password1']        
        try:
            user = PiUser.objects.create_user(email, email, password)    
            if user is not None:  
                user.first_name =  first_name
                user.last_name = last_name
                user.is_staff = True  
                user.save()  
                user = authenticate(username=email, password=password)
                login(request, user)    
                ret = 'Ok'
                t = get_template('register_return.html')
                c = RequestContext(request,locals())
                return HttpResponse(t.render(c))
        except:  
            ret = 'Fail'
            t = get_template('register_return.html')
            c = RequestContext(request,locals())
            return HttpResponse(t.render(c))
    else:
        t = get_template('register.html')
        c = RequestContext(request,locals())
        return HttpResponse(t.render(c))  
Пример #2
0
def dashboard(request, title='dashboard', belong=None):
    pisettings_instance = globaldata.getclient()
    user_count = PiUser.objects.count()   
    device_count = Device.objects.count()   
    if(client.socket_test(pisettings_instance.ip,  pisettings_instance.port)):
        connection = "True"
    else:
        connection = "False"

    applist = globaldata.pci_list.applist()
    app_num = len(applist)
    media_root = settings.MEDIA_ROOT
    DEVICE = Device.objects.all()
    try:
        home_instance = Home.objects.get(id =1)
        home_exist = True
    except:
        home_exist = False

    #logfile
    pihome_log_file = open(globaldata.BASE_DIR + '/log/pihome.log', 'r')
    pihome_log_lines = pihome_log_file.readlines()
    pihome_log = utils.lineslimit(pihome_log_lines, 100)
    cpp_log_file = open(globaldata.BASE_DIR + '/log/pihome.log', 'r')
    cpp_log_lines = cpp_log_file.readlines()
    cpp_log = utils.lineslimit(cpp_log_lines, 100)

    t = get_template('dashboard/dashboard.html')
    c = RequestContext(request,locals())
    return HttpResponse(t.render(c))
Пример #3
0
def register_view(request):
    pisettings_instance = globaldata.getclient()
    if pisettings_instance.enable_register != True:
        return HttpResponse("You are not be allowed to register")
    form = PiRegisterForm(request.POST or None)
    if form.is_valid():
        first_name = form.cleaned_data['first_name']
        last_name = form.cleaned_data['last_name']
        email = form.cleaned_data['email']
        password = form.cleaned_data['password1']
        try:
            user = PiUser.objects.create_user(email, email, password)
            if user is not None:
                user.first_name = first_name
                user.last_name = last_name
                user.is_staff = True
                user.save()
                user = authenticate(username=email, password=password)
                login(request, user)
                ret = 'Ok'
                t = get_template('register_return.html')
                c = RequestContext(request, locals())
                return HttpResponse(t.render(c))
        except:
            ret = 'Fail'
            t = get_template('register_return.html')
            c = RequestContext(request, locals())
            return HttpResponse(t.render(c))
    else:
        t = get_template('register.html')
        c = RequestContext(request, locals())
        return HttpResponse(t.render(c))
Пример #4
0
def dashboard(request, title='dashboard', belong=None):
    pisettings_instance = globaldata.getclient()
    user_count = PiUser.objects.count()
    device_count = Device.objects.count()
    if (client.socket_test(pisettings_instance.ip, pisettings_instance.port)):
        connection = "True"
    else:
        connection = "False"

    applist = globaldata.pci_list.applist()
    app_num = len(applist)
    media_root = settings.MEDIA_ROOT
    DEVICE = Device.objects.all()
    try:
        home_instance = Home.objects.get(id=1)
        home_exist = True
    except:
        home_exist = False

    #logfile
    pihome_log_file = open(globaldata.BASE_DIR + '/log/pihome.log', 'r')
    pihome_log_lines = pihome_log_file.readlines()
    pihome_log = utils.lineslimit(pihome_log_lines, 100)
    cpp_log_file = open(globaldata.BASE_DIR + '/log/pihome.log', 'r')
    cpp_log_lines = cpp_log_file.readlines()
    cpp_log = utils.lineslimit(cpp_log_lines, 100)

    t = get_template('dashboard/dashboard.html')
    c = RequestContext(request, locals())
    return HttpResponse(t.render(c))
Пример #5
0
def settings_general_api(request):
    pisettings_instance = globaldata.getclient()
    form = PiSettingsForm(request.POST or None, instance=pisettings_instance)
    if form.is_valid():
        form.save()
        form = PiSettingsForm(instance=pisettings_instance)
    t = get_template('settings/api_general.html')
    c = RequestContext(request, locals())
    return HttpResponse(t.render(c))
Пример #6
0
Файл: api.py Проект: CN-P5/PiBox
def settings_general_api(request):
    pisettings_instance = globaldata.getclient()
    form = PiSettingsForm(request.POST or None, instance = pisettings_instance)
    if form.is_valid():
        form.save()
        form = PiSettingsForm(instance = pisettings_instance)
    t = get_template('settings/api_general.html')
    c = RequestContext(request,locals())
    return HttpResponse(t.render(c))
Пример #7
0
def  status_default_view(request, title='default', belong=['status']):
    pisettings_instance = globaldata.getclient()

    message = { "title" : "status"}
    message['cmd'] = 'get';

    pi_ret = client.socketjson_send_recv(pisettings_instance.ip,  pisettings_instance.port, message)

    t = get_template('status/default.html')
    c = RequestContext(request,locals())
    return HttpResponse(t.render(c))
Пример #8
0
def status_default_view(request, title='default', belong=['status']):
    pisettings_instance = globaldata.getclient()

    message = {"title": "status"}
    message['cmd'] = 'get'

    pi_ret = client.socketjson_send_recv(pisettings_instance.ip,
                                         pisettings_instance.port, message)

    t = get_template('status/default.html')
    c = RequestContext(request, locals())
    return HttpResponse(t.render(c))
Пример #9
0
def dashboard_api(request):
    pisettings_instance = globaldata.getclient()

    pi_ret = {'nas': globaldata.NasEnable}
    if (client.socket_test(pisettings_instance.ip, pisettings_instance.port)):
        pi_ret['connection'] = "TRUE"
    else:
        pi_ret['connection'] = "FALSE"
    pi_ret['app_num'] = len(globaldata.AppList)

    pi_ret['user_count'] = PiUser.objects.count()

    return HttpResponse(simplejson.dumps(pi_ret))
Пример #10
0
Файл: api.py Проект: CN-P5/PiBox
def dashboard_api(request):
    pisettings_instance = globaldata.getclient()

    pi_ret = {'nas': globaldata.NasEnable}
    if(client.socket_test(pisettings_instance.ip,  pisettings_instance.port)):
        pi_ret['connection'] = "TRUE"
    else:
        pi_ret['connection'] = "FALSE"
    pi_ret['app_num'] =   len(globaldata.AppList)

    pi_ret['user_count'] = PiUser.objects.count()

    return HttpResponse(simplejson.dumps(pi_ret))
Пример #11
0
Файл: api.py Проект: CN-P5/PiBox
def nas_api(request):
    pisettings_instance = globaldata.getclient()
      
    message = { "title" : "nas"}
    if request.method == 'GET':
        try:
            message['cmd'] =  request.GET['cmd'] ;
        except: 
            message['cmd'] =  '' ;

    pi_ret = client.socketjson_send_recv(pisettings_instance.ip,  pisettings_instance.port, message)

    return HttpResponse(simplejson.dumps(pi_ret.message))  
Пример #12
0
def nas_api(request):
    pisettings_instance = globaldata.getclient()

    message = {"title": "nas"}
    if request.method == 'GET':
        try:
            message['cmd'] = request.GET['cmd']
        except:
            message['cmd'] = ''

    pi_ret = client.socketjson_send_recv(pisettings_instance.ip,
                                         pisettings_instance.port, message)

    return HttpResponse(simplejson.dumps(pi_ret.message))
Пример #13
0
def register_api(request):
    pisettings_instance = globaldata.getclient()
    if pisettings_instance.enable_register != True:
        return HttpResponse("You are not be allowed to register")
    form = PiRegisterForm(request.POST or None)
    if form.is_valid():
        first_name = form.cleaned_data['first_name']
        last_name = form.cleaned_data['last_name']
        email = form.cleaned_data['email']
        password = form.cleaned_data['password1']
        user = PiUser.objects.create_user(email, email, password)
        if user is not None:
            user.first_name = first_name
            user.last_name = last_name
            user.is_staff = True
            user.save()
            return HttpResponse(simplejson.dumps({'msg': 'ok'}))
        else:
            return HttpResponse(simplejson.dumps({'msg': 'fail'}))
Пример #14
0
Файл: api.py Проект: CN-P5/PiBox
def register_api(request):    
    pisettings_instance = globaldata.getclient()
    if pisettings_instance.enable_register != True:
        return HttpResponse("You are not be allowed to register") 
    form = PiRegisterForm(request.POST or None)
    if form.is_valid():
        first_name=form.cleaned_data['first_name']
        last_name=form.cleaned_data['last_name']      
        email = form.cleaned_data['email'] 
        password=form.cleaned_data['password1']
        user = PiUser.objects.create_user(email, email, password)    
        if user is not None:  
            user.first_name =  first_name
            user.last_name = last_name
            user.is_staff = True  
            user.save()  
            return HttpResponse(simplejson.dumps({'msg':'ok'}))  
        else:  
            return HttpResponse(simplejson.dumps({'msg':'fail'}))