def index(): import configparser import os if 'passwd' not in os.listdir(): if request.method == 'POST': user_name = request.form['user_name'] passwd = request.form['passwd'] user.new_user(user_name, passwd) else: return render_template('add_user.html', new_user=True) return redirect(url_for('index')) if 'logged_in' in session and session['logged_in'] == True: if request.method == 'POST': config = configparser.ConfigParser() config.read('/etc/ansible/ansible.cfg') for form_key in request.form: section, key = form_key.split("@") config[section][key] = request.form[form_key] with open('/etc/ansible/ansible.cfg', 'w') as configfile: config.write(configfile) return redirect(url_for('index')) else: config = configparser.ConfigParser() config.read('/etc/ansible/ansible.cfg') config['defaults']['ansible_managed'] = '' config['defaults'].pop('ansible_managed') return render_template('index.html', config=config) else: return render_template('index.html')
def index(): import configparser import os if 'passwd' not in os.listdir(): if request.method== 'POST': user_name= request.form['user_name'] passwd= request.form['passwd'] user.new_user(user_name, passwd) else: return render_template('add_user.html', new_user=True) return redirect(url_for('index')) if 'logged_in' in session and session['logged_in']== True: if request.method== 'POST': config= configparser.ConfigParser() config.read('/etc/ansible/ansible.cfg') for form_key in request.form: section, key= form_key.split("@") config[section][key]= request.form[form_key] with open('/etc/ansible/ansible.cfg', 'w') as configfile: config.write(configfile) return redirect(url_for('index')) else: config= configparser.ConfigParser() config.read('/etc/ansible/ansible.cfg') config['defaults']['ansible_managed']='' config['defaults'].pop('ansible_managed') return render_template('index.html', config= config) else: return render_template('index.html')
def yeni_ogrenci(): o = Ogrenci() o.tckn = ints(length=11) o.ad = fake.first_name() o.soyad = fake.last_name() o.cinsiyet = gender() o.uyruk = fake.country() o.medeni_hali = marital_status(student=True) o.ikamet_adresi = fake.address() o.ikamet_il = fake.state() o.ikamet_ilce = fake.state() o.e_posta = fake.email() o.kan_grubu = blood_type() o.ehliyet = driver_license_class() o.cuzdan_seri = id_card_serial() o.cuzdan_seri_no = ints(length=10) o.baba_adi = fake.first_name_male() o.ana_adi = fake.first_name_female() o.dogum_tarihi = birth_date(student=True) o.dogum_yeri = fake.state() o.tel_no = fake.phone_number() username = fake.slug(u'%s-%s' % (o.ad, o.soyad)) user = new_user(username=username) o.user = user o.save() return o
def yeni_ogrenci(): o = Ogrenci() o.tckn = ints(length=11) o.ad = fake.first_name() o.soyad = fake.last_name() o.cinsiyet = gender() o.uyruk = fake.country() o.medeni_hali = marital_status(student=True) o.ikamet_adresi = fake.address() o.ikamet_il = fake.state() o.ikamet_ilce = fake.state() o.adres_2 = fake.address() o.adres_2_posta_kodu = fake.postcode() o.oda_no = fake.classroom_code() o.e_posta = fake.email() o.web_sitesi = "http://%s" % fake.domain_name() o.yayinlar = "\n".join(fake.paragraphs()) o.projeler = "\n".join(fake.paragraphs()) o.kan_grubu = blood_type() o.ehliyet = driver_license_class() o.cuzdan_seri = id_card_serial() o.cuzdan_seri_no = ints(length=10) o.baba_adi = fake.first_name_male() o.ana_adi = fake.first_name_female() o.dogum_tarihi = birth_date(student=True) o.dogum_yeri = fake.state() o.tel_no = fake.phone_number() username = fake.slug(u"%s-%s" % (o.ad, o.soyad)) user = new_user(username=username) o.user = user o.save()
def yeni_ogrenci(self, ogrenci_say=1, program=None, personel=None, user=None): """ Rastgele veriler kullanarak yeni öğrenci kaydı oluştururup kaydeder. Oluşturulan kayıtları liste olarak döndürür. Args: ogrenci_say (int): Oluşturulacak ogrenci sayısı program (object): Ogrencinin kaydedilecegi program personel (object): Ogrencinin programdaki danisamani user (object): Ogrencinin atanacagi user Returns: Ogrenci (list): Yeni öğrenci kaydı """ ogrenci_list = [] for i in range(ogrenci_say): o = Ogrenci() o.tckn = ints(length=11) o.ad = fake.first_name() o.soyad = fake.last_name() o.cinsiyet = gender() o.uyruk = fake.country() o.medeni_hali = marital_status(student=True) o.ikamet_adresi = fake.address() o.ikamet_il = fake.state() o.ikamet_ilce = fake.state() o.e_posta = fake.email() o.kan_grubu = blood_type() o.ehliyet = driver_license_class() o.cuzdan_seri = id_card_serial() o.cuzdan_seri_no = ints(length=10) o.baba_adi = fake.first_name_male() o.ana_adi = fake.first_name_female() o.dogum_tarihi = birth_date(student=True) o.dogum_yeri = fake.state() o.tel_no = fake.phone_number() if user: o.user = user else: username = fake.slug(u'%s-%s' % (o.ad, o.soyad)) user = new_user(username=username) o.user = user o.save() ogrenci_list.append(o) if program and personel: self.yeni_ogrenci_program(ogrenci=o, program=program, personel=personel) return ogrenci_list
def yeni_personel(personel_turu=1): """ Rastgele verileri ve parametre olarak verilen veriyi kullanarak yeni personel kaydı oluştururup kaydeder. Args: personel_turu (Personel): Personel türü Returns: Personel: Yeni personel kaydı """ p = Personel() p.tckn = ints(length=11) p.ad = fake.first_name() p.soyad = fake.last_name() p.cinsiyet = gender() p.uyruk = fake.country() p.medeni_hali = marital_status(student=False) p.ikamet_adresi = fake.address() p.ikamet_il = fake.state() p.ikamet_ilce = fake.state() p.adres_2 = fake.address() p.adres_2_posta_kodu = fake.postcode() p.oda_no = fake.classroom_code() p.oda_tel_no = fake.phone_number() p.cep_telefonu = fake.phone_number() p.e_posta = fake.email() p.e_posta_2 = fake.email() p.e_posta_3 = fake.email() p.web_sitesi = "http://%s" % fake.domain_name() p.yayinlar = '\n'.join(fake.paragraphs()) p.projeler = '\n'.join(fake.paragraphs()) p.kan_grubu = blood_type() p.ehliyet = driver_license_class() p.verdigi_dersler = '\n'.join([fake.lecture() for _ in range(3)]) p.unvan = random.choice(range(1, 5)) p.biyografi = '\n'.join(fake.paragraphs(5)) p.notlar = '\n'.join(fake.paragraphs(1)) p.personel_turu = personel_turu p.cuzdan_seri = id_card_serial() p.cuzdan_seri_no = ints(length=10) p.baba_adi = fake.first_name_male() p.ana_adi = fake.first_name_female() p.dogum_tarihi = birth_date(student=False) p.dogum_yeri = fake.state() p.medeni_hali = random.choice(['1', '2']) p.hizmet_sinifi = random.choice(range(1, 30)) username = fake.slug(u'%s-%s' % (p.ad, p.soyad)) user = new_user(username=username) p.user = user p.save() return p
def register_user(self, username, password, email): """ create a new user only if its username is not already in the system """ u = self.get_user_by_email(email) if u is not None: return None u = user_module.new_user(username, password, email) self.add_user(u) return u
def signup(): connection = pymongo.Connection(connection_string, safe=True) username = request.forms.get("username") password = request.forms.get("password") # set these up in case we have an error case errors = {'username_value': cgi.escape(username), 'username': ''} if user.validate_signup(username, password, errors): if not user.new_user(connection, username, password): # this was a duplicate errors['username_error'] = "Username already in use. Please choose another" return template("signup", errors) session_id = user.start_session(connection, username) print session_id cookie = user.make_secure_val(session_id) response.set_cookie("session", cookie) redirect("/main") else: print "user did not validate" return template("signup", errors)
def yeni_ogrenci(): """ Rastgele verileri kullanarak yeni öğrenci kaydı oluştururup kaydeder. """ o = Ogrenci() o.tckn = ints(length=11) o.ad = fake.first_name() o.soyad = fake.last_name() o.cinsiyet = gender() o.uyruk = fake.country() o.medeni_hali = marital_status(student=True) o.ikamet_adresi = fake.address() o.ikamet_il = fake.state() o.ikamet_ilce = fake.state() o.adres_2 = fake.address() o.adres_2_posta_kodu = fake.postcode() o.oda_no = fake.classroom_code() o.e_posta = fake.email() o.web_sitesi = "http://%s" % fake.domain_name() o.yayinlar = '\n'.join(fake.paragraphs()) o.projeler = '\n'.join(fake.paragraphs()) o.kan_grubu = blood_type() o.ehliyet = driver_license_class() o.cuzdan_seri = id_card_serial() o.cuzdan_seri_no = ints(length=10) o.baba_adi = fake.first_name_male() o.ana_adi = fake.first_name_female() o.dogum_tarihi = birth_date(student=True) o.dogum_yeri = fake.state() o.tel_no = fake.phone_number() username = fake.slug(u'%s-%s' % (o.ad, o.soyad)) user = new_user(username=username) o.user = user o.save()
def signup(): connection = pymongo.Connection(connection_string, safe=True) username = request.forms.get("username") password = request.forms.get("password") # set these up in case we have an error case errors = {'username_value': cgi.escape(username), 'username': ''} if user.validate_signup(username, password, errors): if not user.new_user(connection, username, password): # this was a duplicate errors[ 'username_error'] = "Username already in use. Please choose another" return template("signup", errors) session_id = user.start_session(connection, username) print session_id cookie = user.make_secure_val(session_id) response.set_cookie("session", cookie) redirect("/main") else: print "user did not validate" return template("signup", errors)
def yeni_ogrenci(): """ Rastgele veriler kullanarak yeni öğrenci kaydı oluştururup kaydeder. Returns: Ogrenci: Yeni öğrenci kaydı """ o = Ogrenci() o.tckn = ints(length=11) o.ad = fake.first_name() o.soyad = fake.last_name() o.cinsiyet = gender() o.uyruk = fake.country() o.medeni_hali = marital_status(student=True) o.ikamet_adresi = fake.address() o.ikamet_il = fake.state() o.ikamet_ilce = fake.state() o.e_posta = fake.email() o.kan_grubu = blood_type() o.ehliyet = driver_license_class() o.cuzdan_seri = id_card_serial() o.cuzdan_seri_no = ints(length=10) o.baba_adi = fake.first_name_male() o.ana_adi = fake.first_name_female() o.dogum_tarihi = birth_date(student=True) o.dogum_yeri = fake.state() o.tel_no = fake.phone_number() username = fake.slug(u'%s-%s' % (o.ad, o.soyad)) user = new_user(username=username) o.user = user o.save() return o
def yeni_personel(personel_turu=1, unit='', personel_say=1, user=None): """ Rastgele verileri ve parametre olarak verilen veriyi kullanarak yeni personel kaydı oluştururup kaydeder. Oluşturulan kayıtları liste olarak döndürür. Args: personel_turu (Personel): Personel türü unit (Unit) : Unit nesnesi personel_say : Oluşturulacak personel sayısı user : Personele atanacak user Returns: Personel: Yeni personel listesi """ personel_list = [] for i in range(personel_say): p = Personel() p.tckn = ints(length=11) p.ad = fake.first_name() p.soyad = fake.last_name() p.cinsiyet = gender() p.uyruk = fake.country() p.medeni_hali = marital_status(student=False) p.ikamet_adresi = fake.address() p.ikamet_il = fake.state() p.ikamet_ilce = fake.state() p.adres_2 = fake.address() p.oda_no = fake.classroom_code() p.oda_tel_no = fake.phone_number() p.cep_telefonu = fake.phone_number() p.e_posta = fake.email() p.e_posta_2 = fake.email() p.e_posta_3 = fake.email() p.web_sitesi = "http://%s" % fake.domain_name() p.yayinlar = '\n'.join(fake.paragraphs()) p.projeler = '\n'.join(fake.paragraphs()) p.kan_grubu = blood_type() p.ehliyet = driver_license_class() p.verdigi_dersler = '\n'.join([fake.lecture() for _ in range(3)]) p.unvan = random.choice(range(1, 5)) p.biyografi = '\n'.join(fake.paragraphs(5)) p.notlar = '\n'.join(fake.paragraphs(1)) p.personel_turu = personel_turu p.cuzdan_seri = id_card_serial() p.cuzdan_seri_no = ints(length=10) p.baba_adi = fake.first_name_male() p.ana_adi = fake.first_name_female() p.dogum_tarihi = birth_date(student=False) p.dogum_yeri = fake.state() p.medeni_hali = random.choice(['1', '2']) p.hizmet_sinifi = random.choice(range(1, 30)) p.birim = unit p.gorev_suresi_baslama = ( datetime.datetime.now() - datetime.timedelta(days=random.choice(range(1, 30)))) p.goreve_baslama_tarihi = p.gorev_suresi_baslama p.gorev_suresi_bitis = ( datetime.datetime.now() + datetime.timedelta(days=random.choice(range(1, 30)))) p.kh_sonraki_terfi_tarihi = ( datetime.datetime.now() + datetime.timedelta(days=random.choice(range(1, 30)))) p.ga_sonraki_terfi_tarihi = ( datetime.datetime.now() + datetime.timedelta(days=random.choice(range(1, 30)))) p.em_sonraki_terfi_tarihi = ( datetime.datetime.now() + datetime.timedelta(days=random.choice(range(1, 30)))) p.kazanilmis_hak_derece = random.randint(1, 7) p.kazanilmis_hak_kademe = random.randint(1, 8) p.kazanilmis_hak_ekgosterge = random.randint(1000, 3000) p.gorev_ayligi_derece = random.randint(1, 7) p.gorev_ayligi_kademe = random.randint(1, 8) p.gorev_ayligi_ekgosterge = random.randint(1000, 3000) p.emekli_muktesebat_derece = random.randint(1, 7) p.emekli_muktesebat_kademe = random.randint(1, 8) p.emekli_muktesebat_ekgosterge = random.randint(1000, 3000) p.gorunen_gorev_ayligi_kademe = random.randint(1, 8) p.gorunen_kazanilmis_hak_kademe = random.randint(1, 8) if user: p.user = user else: username = fake.slug(u'%s-%s' % (p.ad, p.soyad)) n_user = new_user(username=username) p.user = n_user p.save() personel_list.append(p) return personel_list
import project import user user_info = user.new_user(header1="EN COOL RUBRIK", header2="EN inte lika cool rubrik", text1="Jag gillar minecraft", text2="Men inte latex", bigimage="finbild.png", links=["github.com"]) #writes new data to the json data file def add_to_db(data): db = load("data.json") db.append(data) with open('data.json', 'w') as file: json.dump(db, file, indent=4) def change_user_info(data): with open('user.json', 'w') as file: json.dump(data, file, indent=4) #edit this to add a new project and uncomment add_to_db(project_temp), run the file, the recomment the same line project_temp = { "start_date": "2009-09-07", "short_description": "no", "course_name": "HOHO", "long_description": "no no no", "group_size": 8,
def yeni_personel(personel_turu=1, unit='', personel_say=1, user=None): """ Rastgele verileri ve parametre olarak verilen veriyi kullanarak yeni personel kaydı oluştururup kaydeder. Oluşturulan kayıtları liste olarak döndürür. Args: personel_turu (Personel): Personel türü unit (Unit) : Unit nesnesi personel_say : Oluşturulacak personel sayısı user : Personele atanacak user Returns: Personel: Yeni personel listesi """ personel_list = [] for i in range(personel_say): p = Personel() p.tckn = ints(length=11) p.ad = fake.first_name() p.soyad = fake.last_name() p.cinsiyet = gender() p.uyruk = fake.country() p.medeni_hali = marital_status(student=False) p.ikamet_adresi = fake.address() p.ikamet_il = fake.state() p.ikamet_ilce = fake.state() p.adres_2 = fake.address() p.oda_no = fake.classroom_code() p.oda_tel_no = fake.phone_number() p.cep_telefonu = fake.phone_number() p.e_posta = fake.email() p.e_posta_2 = fake.email() p.e_posta_3 = fake.email() p.web_sitesi = "http://%s" % fake.domain_name() p.yayinlar = '\n'.join(fake.paragraphs()) p.projeler = '\n'.join(fake.paragraphs()) p.kan_grubu = blood_type() p.ehliyet = driver_license_class() p.verdigi_dersler = '\n'.join([fake.lecture() for _ in range(3)]) p.unvan = random.choice(range(1, 5)) p.biyografi = '\n'.join(fake.paragraphs(5)) p.notlar = '\n'.join(fake.paragraphs(1)) p.personel_turu = personel_turu p.cuzdan_seri = id_card_serial() p.cuzdan_seri_no = ints(length=10) p.baba_adi = fake.first_name_male() p.ana_adi = fake.first_name_female() p.dogum_tarihi = birth_date(student=False) p.dogum_yeri = fake.state() p.medeni_hali = random.choice(['1', '2']) p.hizmet_sinifi = random.choice(range(1, 30)) p.birim = unit p.gorev_suresi_baslama = (datetime.datetime.now() - datetime.timedelta( days=random.choice(range(1, 30)))) p.goreve_baslama_tarihi = p.gorev_suresi_baslama p.gorev_suresi_bitis = (datetime.datetime.now() + datetime.timedelta( days=random.choice(range(1, 30)))) p.kh_sonraki_terfi_tarihi = (datetime.datetime.now() + datetime.timedelta( days=random.choice(range(1, 30)))) p.ga_sonraki_terfi_tarihi = (datetime.datetime.now() + datetime.timedelta( days=random.choice(range(1, 30)))) p.em_sonraki_terfi_tarihi = (datetime.datetime.now() + datetime.timedelta( days=random.choice(range(1, 30)))) p.kazanilmis_hak_derece = random.randint(1, 7) p.kazanilmis_hak_kademe = random.randint(1, 8) p.kazanilmis_hak_ekgosterge = random.randint(1000, 3000) p.gorev_ayligi_derece = random.randint(1, 7) p.gorev_ayligi_kademe = random.randint(1, 8) p.gorev_ayligi_ekgosterge = random.randint(1000, 3000) p.emekli_muktesebat_derece = random.randint(1, 7) p.emekli_muktesebat_kademe = random.randint(1, 8) p.emekli_muktesebat_ekgosterge = random.randint(1000, 3000) p.gorunen_gorev_ayligi_kademe = random.randint(1, 8) p.gorunen_kazanilmis_hak_kademe = random.randint(1, 8) if user: p.user = user else: username = fake.slug(u'%s-%s' % (p.ad, p.soyad)) n_user = new_user(username=username) p.user = n_user p.save() personel_list.append(p) return personel_list