def make_url_model(url, site): """ This should on occur once per newly created URL, the linked count is set to zero if it is a new site added to database """ now = datetime.now() base_url = 'http://links.ep.io/' url_model = Url() url_model.url = url url_short = url try: domain = Domain.objects.get(site=site) domain.linked_count += 1 domain.date_updated = now domain.save() except: domain = Domain(site=site, linked_count=1, date_updated= now) domain.save() url_model.site = domain url_model.date_time_created = datetime.now() url_model.linked_count = 1 url_model.save() url_model.url_shortened = base_url + encode_62(url_model.pk) print url_model.url_shortened url_model.save() return url_model
def run(self): # Fixtures if Domain.objects.count() == 0: domain = Domain(scheme='http', netloc='sametmax.com') url = Url(path='/') domain.urls.append(url) domain.save() for domain in Domain.objects: self._find_links(domain)
def create(self): domain = Domain( name = self.data.get('name'), is_private = self.data.get('is_private') ) if domain.is_https() and domain.is_valid_address(): domain.save() return True else: return False
def index(request): form = DomainForm() if request.method == "POST": form = DomainForm(data=request.POST) if form.is_valid(): domain = form.cleaned_data["domain"] d = Domain(user=request.user, domain=domain) d.save() scan.delay(d.id) messages.add_message(request, messages.INFO, 'Domain başarılı bir şekilde alındı. ' 'Durum takibini Taramalar sayfasından yapabilirsiniz') return render(request, "index.html", locals())
def index(request): form = DomainForm() if request.method == "POST": form = DomainForm(data=request.POST) if form.is_valid(): domain = form.cleaned_data["domain"] d = Domain(user=request.user, domain=domain) d.save() scan.delay(d.id) messages.add_message( request, messages.INFO, 'Domain başarılı bir şekilde alındı. ' 'Durum takibini Taramalar sayfasından yapabilirsiniz') return render(request, "index.html", locals())
def test_creating_new_domains(self): domain = Domain() domain.id = 42 domain.name = "Test VM" domain.state = domain.RUNNING domain.max_memory = 2*2024*2024 domain.memory = domain.max_memory domain.vcpu = 1 domain.save() all_domains_in_database = Domain.objects.all() self.assertEquals(len(all_domains_in_database), 1) only_domain_in_database = all_domains_in_database[0] self.assertEquals(only_domain_in_database, domain) self.assertEquals(only_domain_in_database.name, "Test VM")
def _save(self, results): for href in results: uri = urlparse(href) try: domain = Domain.objects.get(netloc=uri.netloc) except DoesNotExist as e: domain = Domain(scheme=uri.scheme, netloc=uri.netloc) path = uri.path if not path: path = '/' url = Url(path=path) domain.urls.append(url) domain.save()
def saveDomainAndReturnId(domain_name,domain_cname,domain_type, domain_status,disId, etag, project_id, username, new_ip_list,test_url,ignore_param_req): domain = Domain(domain_name=domain_name, domain_cname=domain_cname, domain_type=domain_type, domain_status=domain_status, distribution_id=disId, etag=etag, project_id=project_id, username=username, ip_list=new_ip_list, test_url=test_url, ignore_param_req=ignore_param_req) domain.save() domain_id = Domain.objects.latest('id').id return domain_id