This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Carbon\Carbon; | |
use Illuminate\Database\Eloquent\Relations\HasMany; | |
use Illuminate\Notifications\Notifiable; | |
use Illuminate\Foundation\Auth\User as Authenticatable; | |
use Illuminate\Support\Collection; | |
use Illuminate\Support\Facades\DB; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pesquisar(self, parametro: str, por_pagina=24, idioma='pt-br', tipo='todos', | |
exibir_sugestoes=True): | |
contador = 0 | |
pagina = self._pagina(por_pagina) | |
urls = [ | |
f'{self.URL}/legenda/busca/{parametro}/1/-/{p}/-' for p in range(pagina + 1) | |
] | |
reqs = [requests.get(url=u, headers=self.HEADERS) for u in urls] | |
def _definir_limite(contador: int, por_pagina: int): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import transaction | |
from django.contrib.auth.decorators import login_required | |
@login_required | |
@transaction.atomic | |
def profile(request): | |
if request.method == 'POST': | |
user_form = UserForm(request.POST, instance=request.user) | |
profile_form = ProfileForm(request.POST, instance=request.user.profile) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function($) { | |
$.fn.formset = function(opts) | |
{ | |
var options = $.extend({}, $.fn.formset.defaults, opts), | |
flatExtraClasses = options.extraClasses.join(' '), | |
totalForms = $('#id_' + options.prefix + '-TOTAL_FORMS'), | |
maxForms = $('#id_' + options.prefix + '-MAX_NUM_FORMS'), | |
childElementSelector = 'input,select,textarea,label,div', | |
$$ = $(this), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "base.html" %} | |
{% block content %} | |
<form method="post">{% csrf_token %} | |
{{ forms.subscription }} | |
<input type="submit" value="Subscribe"> | |
</form> | |
<form method="post">{% csrf_token %} | |
{{ forms.contact }} | |
<input type="submit" value="Send"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.utils import timezone | |
class OcorrenciaForm(ModelForm): | |
class Meta: | |
model = Rg_ocorrencia | |
fields = ['criado_em','unidade', 'titulo', 'descricao'] | |
def __init__(self, *args, **kwargs): | |
super().__init__(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PlanForm(forms.ModelForm): | |
class Meta: | |
model = Plan | |
fields = ("price", "title", "description") | |
def __init__(self, *args, **kwargs): | |
super().__init__(self, *args, **kwargs) | |
self.fields["price"].localize = True | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="row"> | |
<table> | |
<tbody> | |
{% for reserva in reservas %} | |
<tr> | |
<td>{{ reserva.user.first_name }}</td> | |
<td>{{ reserva.data }}</td> | |
<td>{{ reserva.turno }}</td> | |
<td>{{ reserva.equipamento_reservado.id }}</td> | |
</tr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def busca(request): | |
filtros = { | |
"categoria": request.GET.get("categoria"), | |
"bairro": request.GET.get("bairro") | |
} | |
trabalhadores = Trabalhador.objects.filter(**filtros) | |
return render(request, "teste.html", {"trabalhadores": trabalhadores}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Authenticator | |
{ | |
const SESSION_KEY = 'auth'; | |
protected $ci; | |
public function __construct() | |
{ |
OlderNewer