Skip to content

Instantly share code, notes, and snippets.

@Oleh-Hrebchuk
Oleh-Hrebchuk / task1.py
Last active March 15, 2016 16:39
oop hulpa
class Lonely(object):
instance = None
def __new__(cls, *args, **kwargs):
if cls.instance is None:
cls.instance=object.__new__(cls)
return cls.instance
def __init__(self, name, lastname):
self.name=name
@Oleh-Hrebchuk
Oleh-Hrebchuk / task1.py
Created March 18, 2016 15:03
decorators
from functools import wraps
def log(func):
@wraps(func)
def wrapper(*args,**kwargs):
if args:
print 'args is: %s, decorated func is: %s, doc: %s ' % (args, func.__name__,func.__doc__)
elif kwargs:
class RevokeCertUsr(forms.Form):
name_cert = forms.CharField(max_length=30)
send_email_cert = forms.EmailField()
<form class="form-inline">
<div class="form-group">
<label class="control-label" for="id_name_vpn">Start Group</label>
<input class="form-control" id="id_name_vpn" maxlength="30"
name="name_vpn" placeholder="Name vpn"
title="Name OpenVPN Service: TestVPN" type="text"/>
<span class="help-block">Start Group</span>
</div>
import json
import datetime
from django.views.generic import TemplateView, FormView
from django.http import HttpResponse
from analyzer.models import BannedMails
from django.db.models import Count
from django.core import serializers
from forms import SearchFilterForm
from django.shortcuts import HttpResponse
from myscripts import SearchFilter
class SearchFilterView(TemplateView, SearchFilter):
template_name = 'search_filters.html'
success_url = '/analyzer/search_filter/'
filters = None
print 'fil',filters
def get_context_data(self, **kwargs):
form = SearchFilterForm
context = super(SearchFilterView, self).get_context_data(**kwargs)
context['form'] = form
if len(self.filters) != 0:
class SearchFilterView(TemplateView, SearchFilter, ConvertData, Config, SliceData):
template_name = 'search_filters.html'
success_url = '/analyzer/search_filter/'
filters = {}
#filters.clear()
c = Config()
paginate_by = 50
path_xml = c.get_value_confing('general', 'path_xml')
def dispatch(self, request, *args, **kwargs):
class LdapPattern(forms.Form):
ldap_start_name = forms.CharField(max_length=50, required=False, label='Start Name Group')
ldap_end_name = forms.CharField(max_length=50, required=False, label='End Name Group')
class LdapForm(forms.Form):
URL = forms.CharField(max_length=30, label='LDAP Server',
help_text='Set DNS or IP address server')
BindDN = forms.CharField(max_length=200, label='Bind DN',
help_text='Set user: user@domain.local')
Password = forms.CharField(max_length=200, label='Password', )
class LdapView(DecoratorBaseClass, FormView):
form_class = LdapForm
template_name = 'atmz_ldap_configuration.html'
vpn_id = 1
success_url = '/vpn_routing_manage/ldap_view/{}/'.format(vpn_id)
def dispatch(self, request, *args, **kwargs):
print 'dispatch', request
if 'vpn_id' in kwargs:
self.vpn_id = kwargs.get('vpn_id')
class Ldapmixin(object):
vpn_id = None
def dispatch(self, request, *args, **kwargs)
if 'vpn_id' in kwargs:
self.vpn_id = kwargs.get('vpn_id')
return super(LdapView, self).dispatch(request, args, kwargs)