def add_domain(subdomain='www'): if not current_user.admin: flash( "You are not admin of your company account, you cannot modify the authenication settings", "danger") return redirect(url_for('main.index', subdomain=subdomain)) else: form = AddDomainForm(fully_managed_domain=True) if form.validate_on_submit(): # TODO verify that the domain is not in a blacklisted list checkDomain = Domains.query.filter_by(name=form.name.data).first() if checkDomain is None: domain = Domains( name=form.name.data, fully_managed_domain=form.fully_managed_domain.data, company_id=current_user.company_id) db.session.add(domain) db.session.commit() flash("You add a new domain to your company", "success") return redirect(url_for("main.index", subdomain=subdomain)) else: flash("The domain is already in your list", "warning") return render_template("add_domain.html", subdomain=subdomain, title="Add your company mail domain", form=form)
def save_csv_to_db(file_path): df = pd.read_csv(file_path) for index in df.index: # dt.datetime.now is bad, change this in the near future domain = Domains(df.ix[index]["domain"], dt.datetime.now()) db.session.add(domain) db.session.commit()
def add_domain(subdomain='www'): form = AddDomainForm() # form.email(disabled=True) if form.validate_on_submit(): domain = Domains(name=form.name.data, fully_managed_domain=form.fully_managed_domain.data, company_id=form.company_id.data) db.session.add(domain) db.session.commit() flash("You added a new domain.", "success") return redirect(url_for("admin.domains", subdomain=subdomain)) return render_template("admin/edit_domain.html", subdomain=subdomain, title="Add domain", form=form)
def initialdomains(): Dicts = os.path.join('initialize', 'domains.list') tasks = list(set([x.strip() for x in open(Dicts, 'r').readlines()])) for task in tasks: try: print('当前检测URL:{}'.format(task)) res = BeiAn(task).scan_seo() bid = str(res.get('备案编号')) bsex = str(res.get('备案性质')) bname = str(res.get('备案名称')) print(bid, bname, bsex) BA = Domains() BA.url = task.lower() BA.BA_sex = bsex BA.BA_name = bname BA.BA_id = bid BA.save() except Exception as e: print(e)
def create_company(subdomain='www'): if not current_user.is_authenticated: return redirect(url_for("auth.login", subdomain=subdomain)) domain = current_user.email.split('@')[1] name = domain.split(".")[0] query_domain = Domains.query.filter_by(name=domain).first() if query_domain is not None: if query_domain.fully_managed_domain == 1: current_user.company_id = query_domain.company_id db.session.add(current_user) db.session.commit() return redirect(url_for("main.index", subdomain=subdomain)) else: return redirect( url_for("main.invitation_required", subdomain=subdomain)) form = CreateCompanyForm(name=name, fully_managed_domain=True) if form.validate_on_submit(): company = Company(name=form.name.data) db.session.add(company) db.session.commit() db.session.refresh(company) domain = Domains(name=domain, fully_managed_domain=form.fully_managed_domain.data, company_id=company.id) db.session.add(domain) current_user.company_id = company.id current_user.admin = True db.session.commit() flash( "Congratulations, your company has been registered! You can add other email domains in your profile", "success") return redirect(url_for("main.index", subdomain=subdomain)) return render_template("auth/create_company.html", subdomain=subdomain, title="Create company", form=form, domain=domain)
req.text)[0] r = req.content.decode(encoding, 'replace') except Exception as e: print('第4次请求失败....') self.result['备案编号'] = self.get_info_from_pattren(self.whois_id, r) self.result['备案性质'] = self.get_info_from_pattren(self.whois_type, r) self.result['备案名称'] = self.get_info_from_pattren(self.whois_name, r) return self.result if __name__ == '__main__': tasks = [x.strip() for x in open('domains.list', 'r').readlines()] for task in tasks: try: print('当前检测URL:{}'.format(task)) res = BeiAn(task).scan_seo() bid = str(res.get('备案编号')) bsex = str(res.get('备案性质')) bname = str(res.get('备案名称')) print(bid, bname, bsex) BA = Domains() BA.url = task.lower() BA.BA_sex = bsex BA.BA_name = bname BA.BA_id = bid BA.save() except Exception as e: print(e)