Best Python code snippet using pyatom_python
admin.py
Source:admin.py
1#!/usr/bin/python -u2# -*- coding: utf-8 -*-3from listasTematicas.models import *4from especies.models import *5from django import forms6from django.contrib import admin7from django.contrib.auth.models import User8from django.http import HttpResponseRedirect,HttpResponse9from django.shortcuts import render, render_to_response1011from posiciones.autocomplete.widgets import *1213#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::14class SpagricolasAdmin(AutocompleteModelAdmin):15 related_search_fields = { 16 'especie': ('id',),17 }18 def formfield_for_foreignkey(self, db_field, request, **kwargs):19 if db_field.name == "userupdate":20 kwargs["queryset"] = User.objects.filter(id=request.user.id)21 return super(SpagricolasAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) 22 class Media:23 js = ('/js/tiny_mce/tiny_mce.js', '/js/textareas.js') 24admin.site.register(Spagricolas,SpagricolasAdmin)2526#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::27class SpagricolamodsAdmin(AutocompleteModelAdmin):28 related_search_fields = { 29 'especie': ('id',),30 }31 def formfield_for_foreignkey(self, db_field, request, **kwargs):32 if db_field.name == "userupdate":33 kwargs["queryset"] = User.objects.filter(id=request.user.id)34 return super(SpagricolamodsAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) 35 class Media:36 js = ('/js/tiny_mce/tiny_mce.js', '/js/textareas.js')37admin.site.register(Spagricolamods,SpagricolamodsAdmin)383940#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::41class SpaprovechablesAdmin(AutocompleteModelAdmin):42 related_search_fields = { 43 'especie': ('id',),44 }45 def formfield_for_foreignkey(self, db_field, request, **kwargs):46 if db_field.name == "userupdate":47 kwargs["queryset"] = User.objects.filter(id=request.user.id)48 return super(SpaprovechablesAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) 49 class Media:50 js = ('/js/tiny_mce/tiny_mce.js', '/js/textareas.js')51admin.site.register(Spaprovechables,SpaprovechablesAdmin)5253#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::54class SpaprovechablemodsAdmin(AutocompleteModelAdmin):55 related_search_fields = { 56 'especie': ('id',),57 }58 def formfield_for_foreignkey(self, db_field, request, **kwargs):59 if db_field.name == "userupdate":60 kwargs["queryset"] = User.objects.filter(id=request.user.id)61 return super(SpaprovechablemodsAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) 62 class Media:63 js = ('/js/tiny_mce/tiny_mce.js', '/js/textareas.js')64admin.site.register(Spaprovechablemods,SpaprovechablemodsAdmin)656667#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::68class SpaprovechamientosustentablesAdmin(AutocompleteModelAdmin):69 related_search_fields = { 70 'especie': ('id',),71 }72 def formfield_for_foreignkey(self, db_field, request, **kwargs):73 if db_field.name == "userupdate":74 kwargs["queryset"] = User.objects.filter(id=request.user.id)75 return super(SpaprovechamientosustentablesAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) 76 class Media:77 js = ('/js/tiny_mce/tiny_mce.js', '/js/textareas.js')78admin.site.register(Spaprovechamientosustentables,SpaprovechamientosustentablesAdmin)7980#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::81class SpaprovechamientosustentablemodsAdmin(AutocompleteModelAdmin):82 related_search_fields = { 83 'especie': ('id',),84 }85 def formfield_for_foreignkey(self, db_field, request, **kwargs):86 if db_field.name == "userupdate":87 kwargs["queryset"] = User.objects.filter(id=request.user.id)88 return super(SpaprovechamientosustentablemodsAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) 89 class Media:90 js = ('/js/tiny_mce/tiny_mce.js', '/js/textareas.js')91admin.site.register(Spaprovechamientosustentablemods,SpaprovechamientosustentablemodsAdmin)9293#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::9495admin.site.register(TipoAprovechable)96#admin.site.register(Spsaludtipos)97admin.site.register(TipoAgricola)98#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::99100101#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::102class SpexoticasAdmin(AutocompleteModelAdmin):103 related_search_fields = { 104 'especie': ('id',),105 }106 filter_horizontal = ('exotica',)107 def formfield_for_foreignkey(self, db_field, request, **kwargs):108 if db_field.name == "userupdate":109 kwargs["queryset"] = User.objects.filter(id=request.user.id)110 return super(SpexoticasAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) 111 class Media:112 js = ('/js/tiny_mce/tiny_mce.js', '/js/textareas.js')113114admin.site.register(Spexoticas,SpexoticasAdmin)115116117#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::118class SpexoticamodsAdmin(AutocompleteModelAdmin):119 related_search_fields = { 120 'especie': ('id',),121 }122 def formfield_for_foreignkey(self, db_field, request, **kwargs):123 if db_field.name == "userupdate":124 kwargs["queryset"] = User.objects.filter(id=request.user.id)125 return super(SpexoticamodsAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) 126 class Media:127 js = ('/js/tiny_mce/tiny_mce.js', '/js/textareas.js')128admin.site.register(Spexoticamods,SpexoticamodsAdmin)129130#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::131class SppeligrosAdmin(AutocompleteModelAdmin):132 related_search_fields = { 133 'especie': ('id',),134 }135 def formfield_for_foreignkey(self, db_field, request, **kwargs):136 if db_field.name == "userupdate":137 kwargs["queryset"] = User.objects.filter(id=request.user.id)138 return super(SppeligrosAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) 139 class Media:140 js = ('/js/tiny_mce/tiny_mce.js', '/js/textareas.js')141admin.site.register(Sppeligros,SppeligrosAdmin)142143#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::144class SppeligromodsAdmin(AutocompleteModelAdmin):145 related_search_fields = { 146 'especie': ('id',),147 }148 def formfield_for_foreignkey(self, db_field, request, **kwargs):149 if db_field.name == "userupdate":150 kwargs["queryset"] = User.objects.filter(id=request.user.id)151 return super(SppeligromodsAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) 152 class Media:153 js = ('/js/tiny_mce/tiny_mce.js', '/js/textareas.js')154admin.site.register(Sppeligromods,SppeligromodsAdmin)155156admin.site.register(SprepresentativaasMods)157158#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::159class SprepresentativaasAdmin(AutocompleteModelAdmin):160 related_search_fields = { 161 'especie': ('id',),162 }163 def formfield_for_foreignkey(self, db_field, request, **kwargs):164 if db_field.name == "userupdate":165 kwargs["queryset"] = User.objects.filter(id=request.user.id)166 return super(SprepresentativaasAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) 167 class Media:168 js = ('/js/tiny_mce/tiny_mce.js', '/js/textareas.js')169#admin.site.register(Sprepresentativaas,SprepresentativaasAdmin)170171#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::172class SpsaludsAdmin(AutocompleteModelAdmin):173 related_search_fields = { 174 'especie': ('id',),175 }176 filter_horizontal = ('tipo',)177 def formfield_for_foreignkey(self, db_field, request, **kwargs):178 if db_field.name == "userupdate":179 kwargs["queryset"] = User.objects.filter(id=request.user.id)180 return super(SpsaludsAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) 181 class Media:182 js = ('/js/tiny_mce/tiny_mce.js', '/js/textareas.js')183admin.site.register(Spsaluds,SpsaludsAdmin)184185#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::186class SpsaludtiposAdmin(admin.ModelAdmin):187 def formfield_for_foreignkey(self, db_field, request, **kwargs):188 if db_field.name == "userupdate":189 kwargs["queryset"] = User.objects.filter(id=request.user.id)190 return super(SpsaludtiposAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) 191 class Media:192 js = ('/js/tiny_mce/tiny_mce.js', '/js/textareas.js')193admin.site.register(Spsaludtipos,SpsaludtiposAdmin)194195#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::196class SpsaludmodsAdmin(AutocompleteModelAdmin):197 related_search_fields = { 198 'especie': ('id',),199 }200 def formfield_for_foreignkey(self, db_field, request, **kwargs):201 if db_field.name == "userupdate":202 kwargs["queryset"] = User.objects.filter(id=request.user.id)203 return super(SpsaludmodsAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) 204 class Media:205 js = ('/js/tiny_mce/tiny_mce.js', '/js/textareas.js')206admin.site.register(Spsaludmods,SpsaludmodsAdmin)207208#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::209class SptraficosAdmin(AutocompleteModelAdmin):210 related_search_fields = { 211 'especie': ('id',),212 }213 def formfield_for_foreignkey(self, db_field, request, **kwargs):214 if db_field.name == "userupdate":215 kwargs["queryset"] = User.objects.filter(id=request.user.id)216 return super(SptraficosAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) 217 class Media:218 js = ('/js/tiny_mce/tiny_mce.js', '/js/textareas.js')219admin.site.register(Sptraficos,SptraficosAdmin)220221#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::222class SptraficomodsAdmin(AutocompleteModelAdmin):223 related_search_fields = { 224 'especie': ('id',),225 }226 def formfield_for_foreignkey(self, db_field, request, **kwargs):227 if db_field.name == "userupdate":228 kwargs["queryset"] = User.objects.filter(id=request.user.id)229 return super(SptraficomodsAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) 230 class Media:231 js = ('/js/tiny_mce/tiny_mce.js', '/js/textareas.js')232admin.site.register(Sptraficomods,SptraficomodsAdmin)233234235
...
textareas_tests.py
Source:textareas_tests.py
1from re import compile2import pytest3pytestmark = pytest.mark.page('forms_with_input_elements.html')4class TestTextAreasByValue(object):5 def test_finds_textareas_by_string(self, browser):6 browser.textarea(index=0).set('foo1')7 browser.textarea(index=1).set('foo2')8 assert [e.id for e in browser.textareas(value='foo1')] == [browser.textarea(index=0).id]9 assert [e.id for e in browser.textareas(value='foo2')] == [browser.textarea(index=1).id]10 def test_finds_textareas_by_regexp(self, browser):11 browser.textarea(index=0).set('foo1')12 browser.textarea(index=1).set('foo2')13 assert browser.textareas(value=compile(r'foo'))[0].id == browser.textarea(index=0).id...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!