How to use page_title method in lettuce_webdriver

Best Python code snippet using lettuce_webdriver_python

views.py

Source:views.py Github

copy

Full Screen

1from django.http import HttpResponse2from django.shortcuts import render, redirect3from django.contrib import messages4from django.core.paginator import Paginator5from .filters import *6from django.db.models.functions import Lower7from django.contrib.auth.decorators import login_required8from .models import *9from .forms import *10####################################################11# PLAYERS START12# PLAYERS HOME PAGE, LISTS ALL PLAYERS13@login_required(login_url='account-login')14def playersHome(request):15 players = Player.objects.order_by(Lower('ingame_name')).all()16 myFilter = PlayerFilter(request.GET, queryset = players)17 players = myFilter.qs18 page_title = " - Players"19 context = {'page_title': page_title,'item':players, 'myFilter':myFilter}20 return render(request, 'players/players_home.html', context)21# CREATE NEW PLAYER, OPENS FORM playerForm() from forms.py22@login_required(login_url='account-login')23def createPlayer(request):24 form = playerForm()25 if request.method == 'POST':26 form = playerForm(request.POST)27 if form.is_valid():28 form.save(request.user)29 name = form.cleaned_data.get('ingame_name')30 messages.success(request, 'New player created: ' + name)31 return redirect('players-home')32 page_title = " - Add new player"33 context = {'page_title': page_title,'form': form}34 return render(request, 'players/players_form.html', context)35# UPDATE PLAYER, OPENS FORM playerForm() from forms.py36@login_required(login_url='account-login')37def updatePlayer(request, pk):38 player = Player.objects.get(id=pk)39 form = playerForm(instance=player)40 if request.method == 'POST':41 form = playerForm(request.POST, instance=player)42 if form.is_valid():43 form.save(request.user)44 name = form.cleaned_data.get('ingame_name')45 messages.success(request, 'Player info updated: ' + name)46 return redirect('players-home')47 page_title = " - Update player info"48 context = {'page_title': page_title,'form': form}49 return render(request, 'players/players_form.html', context)50# DELETE PLAYER, OPENS html page players_delete.html51@login_required(login_url='account-login')52def deletePlayer(request, pk):53 player = Player.objects.get(id=pk)54 if request.method == "POST":55 name = player.ingame_name56 player.delete()57 messages.success(request, 'Player deleted: ' + str(name))58 return redirect('players-home')59 page_title = " - Delete Player"60 context = {'page_title': page_title,'item': player}61 return render(request, 'players/players_delete.html', context)62# PLAYERS END63####################################################64####################################################65# SQUADS START66# SQAD HOME PAGE, LISTS ALL SQADS67@login_required(login_url='account-login')68def squadHome(request):69 squads_all = Squad.objects.order_by(Lower('squad_name')).all()70 myFilter = SquadFilter(request.GET, queryset = squads_all)71 squads_all = myFilter.qs72 73 page_title = " - Squads"74 context = {'page_title': page_title,'item':squads_all,'myFilter':myFilter}75 return render(request, 'players/squad_home.html', context)76# CREATE NEW SQUAD, OPENS FORM squadForm() from forms.py77@login_required(login_url='account-login')78def createSquad(request):79 form = squadForm()80 if request.method == 'POST':81 form = squadForm(request.POST)82 if form.is_valid():83 form.save(request.user)84 name = form.cleaned_data.get('squad_name')85 messages.success(request, 'New squad created: ' + name)86 return redirect('squad-home')87 page_title = " - Add new squad"88 context = {'page_title': page_title,'form': form}89 return render(request, 'players/squad_form.html', context)90# UPDATE SQUAD, OPENS FORM squadForm() from forms.py91@login_required(login_url='account-login')92def updateSquad(request, pk):93 squad = Squad.objects.get(id=pk)94 form = squadForm(instance=squad)95 if request.method == 'POST':96 form = squadForm(request.POST, instance=squad)97 if form.is_valid():98 form.save(request.user)99 name = form.cleaned_data.get('squad_name')100 messages.success(request, 'Squad info updated: ' + name)101 return redirect('squad-home')102 page_title = " - Update squad info"103 context = {'page_title': page_title,'form': form}104 return render(request, 'players/squad_form.html', context)105# DELETE SQUAD, OPENS html page squad_delete.html106@login_required(login_url='account-login')107def deleteSquad(request, pk):108 squad = Squad.objects.get(id=pk)109 if request.method == "POST":110 name = squad.squad_name111 squad.delete()112 messages.success(request, 'Squad deleted: ' + str(name))113 return redirect('squad-home')114 page_title = " - Delete Squad"115 context = {'page_title': page_title,'item': squad}116 return render(request, 'players/squad_delete.html', context)117# SQUADS END118####################################################119####################################################120# DONATIONS START121# DONATION HOME PAGE, LISTS ALL DONATIONS122@login_required(login_url='account-login')123def donationHome(request):124 donations = Donation.objects.order_by('-donation_date').all()125 myFilter = DonationFilter(request.GET, queryset = donations)126 donations = myFilter.qs127 page_title = " - Donations"128 context = {'page_title': page_title,'item': donations,'myFilter':myFilter}129 return render(request, 'players/donation_home.html', context)130# CREATE NEW DONATION, OPENS FORM donationForm() from forms.py131@login_required(login_url='account-login')132def createDonation(request):133 form = donationForm()134 if request.method == 'POST':135 form = donationForm(request.POST)136 if form.is_valid():137 form.save(request.user)138 messages.success(request, 'Donation saved.')139 return redirect('donation-home')140 page_title = " - Add new donation"141 context = {'page_title': page_title,'form': form}142 return render(request, 'players/donation_form.html', context)143# UPDATE DONATION, OPENS FORM donationForm() from forms.py144@login_required(login_url='account-login')145def updateDonation(request, pk):146 donation = Donation.objects.get(id=pk)147 form = donationForm(instance=donation)148 if request.method == 'POST':149 form = donationForm(request.POST, instance=donation)150 if form.is_valid():151 form.save(request.user)152 messages.success(request, 'Donation info updated.')153 return redirect('donation-home')154 page_title = " - Update donation info"155 context = {'page_title': page_title,'form': form}156 return render(request, 'players/donation_form.html', context)157# DELETE DONATION, OPENS html page donation_delete.html158@login_required(login_url='account-login')159def deleteDonation(request, pk):160 donation = Donation.objects.get(id=pk)161 if request.method == "POST":162 donation.delete()163 messages.success(request, 'Donation deleted: ' + str(donation))164 return redirect('donation-home')165 page_title = " - Delete Donation"166 context = {'page_title': page_title,'item': donation}167 return render(request, 'players/donation_delete.html', context)168# DONATIONS END169####################################################170####################################################171# VEHICLES START172# VEHICLES HOME PAGE, LISTS ALL VEHICLES173@login_required(login_url='account-login')174def vehicleHome(request):175 vehicles = Vehicle.objects.all()176 myFilter = VehicleFilter(request.GET, queryset = vehicles)177 vehicles = myFilter.qs178 179 page_title = " - Vehicles"180 context = {'page_title': page_title,'item':vehicles,'myFilter':myFilter}181 return render(request, 'players/vehicle_home.html', context)182# CREATE NEW VEHICLE, OPENS FORM vehicleForm() from forms.py183@login_required(login_url='account-login')184def createVehicle(request):185 form = vehicleForm()186 if request.method == 'POST':187 form = vehicleForm(request.POST)188 if form.is_valid():189 form.save(request.user)190 messages.success(request, 'New vehicle added.')191 return redirect('vehicle-home')192 page_title = " - Add new vehicle"193 context = {'page_title': page_title,'form': form}194 return render(request, 'players/vehicle_form.html', context)195# UPDATE VEHICLE, OPENS FORM vehicleForm() from forms.py196@login_required(login_url='account-login')197def updateVehicle(request, pk):198 vehicle = Vehicle.objects.get(id=pk)199 form = vehicleForm(instance=vehicle)200 if request.method == 'POST':201 form = vehicleForm(request.POST, instance=vehicle)202 if form.is_valid():203 form.save(request.user)204 messages.success(request, 'Vehicle info updated.')205 return redirect('vehicle-home')206 page_title = " - Update vehicle info"207 context = {'page_title': page_title,'form': form}208 return render(request, 'players/vehicle_form.html', context)209# DELETE VEHICLE, OPENS html page vehicle_delete.html210@login_required(login_url='account-login')211def deleteVehicle(request, pk):212 vehicle = Vehicle.objects.get(id=pk)213 if request.method == "POST":214 vehicle.delete()215 messages.success(request, 'Vehicle deleted.')216 return redirect('vehicle-home')217 page_title = " - Delete Vehicle"218 context = {'page_title': page_title,'item': vehicle}219 return render(request, 'players/vehicle_delete.html', context)220# VEHICLES END221####################################################222####################################################223# CASES START224# CASES HOME PAGE, LISTS ALL CASES225@login_required(login_url='account-login')226def caseHome(request):227 cases = Case.objects.order_by('-case_date').all()228 myFilter = CaseFilter(request.GET, queryset = cases)229 cases = myFilter.qs230 page_title = " - Cases"231 context = {'page_title': page_title,'item':cases, 'myFilter':myFilter}232 return render(request, 'players/case_home.html', context)233# CREATE NEW CASE, OPENS FORM caseForm() from forms.py234@login_required(login_url='account-login')235def createCase(request):236 form = caseForm()237 if request.method == 'POST':238 form = caseForm(request.POST)239 if form.is_valid():240 form.save(request.user)241 messages.success(request, 'New case created.')242 return redirect('case-home')243 page_title = " - Add new case"244 context = {'page_title': page_title,'form': form}245 return render(request, 'players/case_form.html', context)246# UPDATE CASE, OPENS FORM caseForm() from forms.py247@login_required(login_url='account-login')248def updateCase(request, pk):249 case = Case.objects.get(id=pk)250 form = caseForm(instance=case)251 if request.method == 'POST':252 form = caseForm(request.POST, instance=case)253 if form.is_valid():254 form.save(request.user)255 messages.success(request, 'Case data updated.')256 return redirect('case-home')257 page_title = " - Update case info"258 context = {'page_title': page_title,'form': form}259 return render(request, 'players/case_form.html', context)260# DELETE CASE, OPENS html page case_delete.html261@login_required(login_url='account-login')262def deleteCase(request, pk):263 case = Case.objects.get(id=pk)264 if request.method == "POST":265 case.delete()266 messages.success(request, 'Case deleted.')267 return redirect('case-home')268 page_title = " - Delete Case"269 context = {'page_title': page_title,'item': case}270 return render(request, 'players/case_delete.html', context)271# CASES END272####################################################273####################################################274# FLAGS START275# FLAGS HOME PAGE, LISTS ALL FLAGS276@login_required(login_url='account-login')277def flagHome(request):278 flags = Flag.objects.order_by('-modified').all()279 myFilter = FlagFilter(request.GET, queryset = flags)280 flags = myFilter.qs281 page_title = " - Flags"282 context = {'page_title': page_title,'item':flags, 'myFilter':myFilter}283 return render(request, 'players/flag_home.html', context)284# CREATE NEW FLAG, OPENS FORM flagForm() from forms.py285@login_required(login_url='account-login')286def createFlag(request):287 form = flagForm()288 if request.method == 'POST':289 form = flagForm(request.POST)290 if form.is_valid():291 form.save(request.user)292 messages.success(request, 'New flag created.')293 return redirect('flag-home')294 page_title = " - Add new flag"295 context = {'page_title': page_title,'form': form}296 return render(request, 'players/flag_form.html', context)297# UPDATE FLAG, OPENS FORM flagForm() from forms.py298@login_required(login_url='account-login')299def updateFlag(request, pk):300 flag = Flag.objects.get(id=pk)301 form = flagForm(instance=flag)302 if request.method == 'POST':303 form = flagForm(request.POST, instance=flag)304 if form.is_valid():305 form.save(request.user)306 messages.success(request, 'Flag info updated.')307 return redirect('flag-home')308 page_title = " - Update flag info"309 context = {'page_title': page_title,'form': form}310 return render(request, 'players/flag_form.html', context)311# DELETE FLAG, OPENS html page flag_delete.html312@login_required(login_url='account-login')313def deleteFlag(request, pk):314 flag = Flag.objects.get(id=pk)315 if request.method == "POST": 316 flag.delete()317 messages.success(request, 'Flag deleted.')318 return redirect('flag-home')319 page_title = " - Delete Flag"320 context = {'page_title': page_title,'item': flag}321 return render(request, 'players/flag_delete.html', context)322# FLAGS END...

Full Screen

Full Screen

context.py

Source:context.py Github

copy

Full Screen

1from django.template.loader import render_to_string2from django.shortcuts import reverse3from django.utils.translation import ugettext as _4from django.utils.timezone import now5from django.conf import settings6from django.contrib.staticfiles.templatetags.staticfiles import static7from apps.users.models import News8from apps.main.models import Menu9site_logo = static('images/logo.png')10def get_page_data(request, *args, **kwargs):11 view_name = request.resolver_match.view_name12 kwargs = request.resolver_match.kwargs13 page_title = _('Home page')14 paths = list()15 paths.append({16 'title': page_title,17 'path': reverse('users:cafe_list')18 })19 if view_name == 'users:profile':20 page_title = _('Account Settings')21 paths.append({22 'title': _('Account Settings'),23 'path': reverse(view_name)24 })25 elif view_name == 'main:news_list':26 page_title = _('News')27 paths.append({28 'title': page_title,29 'path': reverse(view_name,),30 })31 elif view_name == 'users:cafe_list':32 page_title = _('Cafe list')33 paths.append({34 'title': page_title,35 'path': reverse(view_name,),36 })37 elif view_name == 'users:settings':38 page_title = _('Settings')39 paths.append({40 'title': page_title,41 'path': reverse(view_name,),42 })43 elif view_name == 'users:cafe_detail':44 paths.append({45 'title': _('Cafe list'),46 'path': reverse('users:cafe_list',),47 })48 page_title = _('Cafe detail')49 paths.append({50 'title': page_title,51 'path': reverse(view_name,),52 })53 elif view_name == 'users:cafe_edit':54 args = [kwargs.get('cafe_id')]55 paths.append({56 'title': _('Cafe list'),57 'path': reverse('users:cafe_list',),58 })59 page_title = _('Cafe detail')60 paths.append({61 'title': page_title,62 'path': reverse('users:cafe_detail', args=args),63 })64 page_title = _('Cafe edit')65 paths.append({66 'title': page_title,67 'path': reverse(view_name, args=args),68 })69 elif view_name == 'users:cafe_add':70 paths.append({71 'title': _('Cafe list'),72 'path': reverse('users:cafe_list',),73 })74 page_title = _('Cafe add')75 paths.append({76 'title': page_title,77 'path': reverse('users:cafe_add',),78 })79 elif view_name == 'users:cafe_week_time_page':80 args = [kwargs.get('cafe_id')]81 paths.append({82 'title': _('Cafe list'),83 'path': reverse('users:cafe_list',),84 })85 page_title = _('Cafe detail')86 paths.append({87 'title': page_title,88 'path': reverse('users:cafe_detail', args=args),89 })90 page_title = _('Cafe edit')91 paths.append({92 'title': page_title,93 'path': reverse('users:cafe_edit', args=args),94 })95 page_title = _('Time graphic')96 paths.append({97 'title': page_title,98 'path': reverse(view_name, args=args),99 })100 elif view_name == 'users:cafe_location_page':101 args = [kwargs.get('cafe_id')]102 paths.append({103 'title': _('Cafe list'),104 'path': reverse('users:cafe_list',),105 })106 page_title = _('Cafe detail')107 paths.append({108 'title': page_title,109 'path': reverse('users:cafe_detail', args=args),110 })111 page_title = _('Cafe edit')112 paths.append({113 'title': page_title,114 'path': reverse('users:cafe_edit', args=args),115 })116 page_title = _('Location settings')117 paths.append({118 'title': page_title,119 'path': reverse(view_name, args=args),120 })121 elif view_name == 'users:cafe_gallery':122 args = [kwargs.get('cafe_id')]123 paths.append({124 'title': _('Cafe list'),125 'path': reverse('users:cafe_list',),126 })127 page_title = _('Cafe detail')128 paths.append({129 'title': page_title,130 'path': reverse('users:cafe_detail', args=args),131 })132 page_title = _('Cafe edit')133 paths.append({134 'title': page_title,135 'path': reverse('users:cafe_edit', args=args),136 })137 page_title = _('Gallery list')138 paths.append({139 'title': page_title,140 'path': reverse(view_name, args=args),141 })142 elif view_name == 'users:cafe_gallery_add':143 args = [kwargs.get('cafe_id')]144 paths.append({145 'title': _('Cafe list'),146 'path': reverse('users:cafe_list',),147 })148 page_title = _('Cafe detail')149 paths.append({150 'title': page_title,151 'path': reverse('users:cafe_detail', args=args),152 })153 page_title = _('Cafe edit')154 paths.append({155 'title': page_title,156 'path': reverse('users:cafe_edit', args=args),157 })158 page_title = _('Gallery list')159 paths.append({160 'title': page_title,161 'path': reverse('users:cafe_gallery', args=args),162 })163 page_title = _('Gallery add')164 paths.append({165 'title': page_title,166 'path': reverse(view_name, args=args),167 })168 elif view_name == 'users:cafe_gallery_delete':169 args = [kwargs.get('cafe_id')]170 paths.append({171 'title': _('Cafe list'),172 'path': reverse('users:cafe_list',),173 })174 page_title = _('Cafe detail')175 paths.append({176 'title': page_title,177 'path': reverse('users:cafe_detail', args=args),178 })179 page_title = _('Cafe edit')180 paths.append({181 'title': page_title,182 'path': reverse('users:cafe_edit', args=args),183 })184 page_title = _('Gallery list')185 paths.append({186 'title': page_title,187 'path': reverse('users:cafe_gallery', args=args),188 })189 page_title = _('Gallery delete')190 args.append(kwargs.get('file_id'))191 paths.append({192 'title': page_title,193 'path': reverse(view_name, args=args),194 })195 elif view_name == 'main:news_detail':196 news_list_title = _('News')197 paths.append({198 'title': news_list_title,199 'path': reverse('main:news_list'),200 })201 arg = kwargs.get('slug')202 news_content = News.objects.get(translations__slug=arg)203 page_title = news_content.name204 paths.append({205 'title': page_title,206 'path': reverse(view_name, args=[arg]),207 })208 elif view_name == 'products:product_list':209 page_title = _('Product list')210 paths.append({211 'title': page_title,212 'path': reverse(view_name,),213 })214 elif view_name == 'products:product_create':215 page_title = _('Product list')216 paths.append({217 'title': page_title,218 'path': reverse('products:product_list',),219 })220 page_title = _('Product create')221 paths.append({222 'title': page_title,223 'path': reverse(view_name,),224 })225 elif view_name == 'products:product_detail':226 args = [kwargs.get('pk')]227 page_title = _('Product list')228 paths.append({229 'title': page_title,230 'path': reverse('products:product_list',),231 })232 page_title = _('Product detail info')233 paths.append({234 'title': page_title,235 'path': reverse(view_name, args=args),236 })237 elif view_name == 'products:product_edit':238 args = [kwargs.get('pk')]239 page_title = _('Product list')240 paths.append({241 'title': page_title,242 'path': reverse('products:product_list',),243 })244 page_title = _('Product detail info')245 paths.append({246 'title': page_title,247 'path': reverse('products:product_detail', args=args),248 })249 page_title = _('Product edit')250 paths.append({251 'title': page_title,252 'path': reverse('products:product_edit', args=args),253 })254 elif view_name == 'products:product_delete':255 args = [kwargs.get('pk')]256 page_title = _('Product list')257 paths.append({258 'title': page_title,259 'path': reverse('products:product_list',),260 })261 page_title = _('Product detail info')262 paths.append({263 'title': page_title,264 'path': reverse('products:product_detail', args=args),265 })266 page_title = _('Product edit')267 paths.append({268 'title': page_title,269 'path': reverse('products:product_edit', args=args),270 })271 page_title = _('Product delete')272 paths.append({273 'title': page_title,274 'path': reverse(view_name, args=args),275 })276 elif view_name == 'users:employee_list':277 page_title = _('Employee list')278 paths.append({279 'title': page_title,280 'path': reverse(view_name, ),281 })282 elif view_name == 'users:employee_edit':283 args = [kwargs.get('employee_id')]284 page_title = _('Employee list')285 paths.append({286 'title': page_title,287 'path': reverse('users:employee_list', ),288 })289 page_title = _('Employee edit')290 paths.append({291 'title': page_title,292 'path': reverse(view_name, args=args),293 })294 elif view_name == 'users:employee_add':295 page_title = _('Employee list')296 paths.append({297 'title': page_title,298 'path': reverse('users:employee_list', ),299 })300 page_title = _('New Employee')301 paths.append({302 'title': page_title,303 'path': reverse(view_name, ),304 })305 elif view_name == 'users:employee_delete':306 args = [kwargs.get('employee_id')]307 page_title = _('Employee list')308 paths.append({309 'title': page_title,310 'path': reverse('users:employee_list', ),311 })312 page_title = _('Delete Employee')313 paths.append({314 'title': page_title,315 'path': reverse(view_name, args=args),316 })317 elif view_name == 'users:employee_add_existing':318 page_title = _('Employee list')319 paths.append({320 'title': page_title,321 'path': reverse('users:employee_list', ),322 })323 page_title = _('Add existing employee')324 paths.append({325 'title': page_title,326 'path': reverse(view_name),327 })328 return {'paths': paths, 'page_title': page_title}329def get_breadcrumbs(request, *args, **kwargs):330 page_data = get_page_data(request, *args, **kwargs)331 return render_to_string('parts/breadcrumbs.html', page_data)332def get_header(request):333 context = dict()334 context['request'] = request335 context['menu_items'] = Menu.objects.order_by('order')336 context['site_name'] = settings.SITE_NAME337 context['site_logo'] = site_logo338 return render_to_string('parts/main_header.html', context=context)339def get_footer(request):340 context = dict()341 context['request'] = request342 context['now'] = now()343 context['site_logo'] = site_logo344 return render_to_string('parts/footer.html', context=context)345def defaults(request, *args, **kwargs):346 breadcrumbs = get_breadcrumbs(request, *args, **kwargs)347 header = get_header(request)348 footer = get_footer(request)349 site_name = settings.SITE_NAME350 page_title = get_page_data(request, *args, **kwargs).get('page_title')...

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 lettuce_webdriver 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