How to use generate_referral method in SeleniumBase

Best Python code snippet using SeleniumBase

urls.py

Source:urls.py Github

copy

Full Screen

1"""mysite URL Configuration2The `urlpatterns` list routes URLs to views. For more information please see:3 https://docs.djangoproject.com/en/3.1/topics/http/urls/4Examples:5Function views6 1. Add an import: from my_app import views7 2. Add a URL to urlpatterns: path('', views.home, name='home')8Class-based views9 1. Add an import: from other_app.views import Home10 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')11Including another URLconf12 1. Import the include() function: from django.urls import include, path13 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))14"""15from django.contrib import admin16from django.urls import path17from referralroulette import views18from django.conf import settings # new19from django.urls import path, include # new20from django.conf.urls.static import static # new21from django.views.static import serve22from django.conf.urls import url23from django.views.generic import RedirectView24handler404 = 'referralroulette.views.custom_page_not_found_view'25handler500 = 'referralroulette.views.custom_error_view'26urlpatterns = [27 path('', views.index, name='index'),28 path('for/', RedirectView.as_view(url='/')), # empty for/ should redirect to index.html29 path('for/<slug:slug>', views.for_service, name='for_service'),30 path('browse', views.browse, name='browse'),31 path('categories', views.categories, name='categories'),32 path('categories/<slug:slug>', views.categories_tag, name='categories_tag'),33 path('faq', views.faq, name='faq'),34 path('contact', views.contact, name='contact'),35 path('policies/cookie', views.cookiepolicy, name='cookiepolicy'),36 path('policies/privacy', views.privacypolicy, name='privacypolicy'),37 path('profile', views.profile, name='profile'),38 path('redirect/<str:slug>', views.redirect, name='redirect'),39 path('api/generatereferral/<str:slug>', views.generate_referral, name='generate_referral'),40 path('api/addreferral', views.add_referral, name='add_referral'),41 path('api/deletereferral/<str:slug>', views.delete_referral, name='delete_referral'),42 path('admin/', admin.site.urls),43 path('tinymce/', include('tinymce.urls')),44 path('accounts/', include('allauth.urls')),45 url(r'^media/(?P<path>.*)$', serve,{'document_root': settings.MEDIA_ROOT}),46 url(r'^static/(?P<path>.*)$', serve,{'document_root': settings.STATIC_ROOT}),...

Full Screen

Full Screen

models.py

Source:models.py Github

copy

Full Screen

...15 auth_provider = models.CharField(max_length=255, null=True, blank=True)16 #references = models.ManyToManyField("self", blank=True, through='Referral', symmetrical=False, related_name='related_referrals+')17 created_at = models.DateTimeField(auto_now_add=True)18 updated_at = models.DateTimeField(auto_now=True)19 def generate_referral(self, *args, **kwargs):20 initials = "AUG"21 token_len = 822 chars= string.ascii_uppercase + string.digits23 token= ''.join(random.choice(chars) for _ in range(token_len)) #make 8 character long unique key24 return initials + str(token)25 def clean(self, *args, **kwargs):26 if self.referral_code:27 self.referral_code28 else:29 self.referral_code = self.generate_referral()30 def __str__(self):31 return self.email32class Referral(models.Model):33 code = models.CharField(max_length=255, null=True, blank=True)34 user = models.ManyToManyField(AugustUser, blank=True)35 def __str__(self):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeleniumBase automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful