-
Empty Form:
- Test an empty form to ensure it is invalid.
- Verify that the form errors match the expected errors for required fields.
-
Form with Invalid Data:
- Test the form with intentionally invalid data.
- Check that the form is marked as invalid and contains appropriate error messages.
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.core.management.base import BaseCommand | |
from rq.registry import FailedJobRegistry | |
from django_rq.queues import get_queue | |
from django_rq.utils import get_jobs | |
class Command(BaseCommand): | |
help = 'Delete failed jobs from Django RQ.' |
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
import math | |
def custom_round(number): | |
# Multiply by 100 and check if the last two digits are >= 45 | |
decimal_part = (number * 100) % 100 | |
# If the decimal part is >= 45, round up | |
if decimal_part >= 45: | |
return math.ceil(number) | |
else: |
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
#!/usr/bin/env python | |
""" Short description of this Python module. | |
Longer description of this module. | |
This program is free software: you can redistribute it and/or modify it under | |
the terms of the GNU General Public License as published by the Free Software | |
Foundation, either version 3 of the License, or (at your option) any later | |
version. |
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
import os | |
import glob | |
def delete_migrations(app_name): | |
# Get the path to the migrations folder of the app | |
migrations_path = os.path.join(app_name, 'migrations') | |
# Check if the migrations folder exists | |
if os.path.exists(migrations_path): | |
# Find all migration files (except __init__.py) in the migrations folder |
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
// Run this in the F12 javascript console in chrome | |
// if a redirect happens, the page will pause | |
// this helps because chrome's network tab's | |
// "preserve log" seems to technically preserve the log | |
// but you can't actually LOOK at it... | |
// also the "replay xhr" feature does not work after reload | |
// even if you "preserve log". | |
window.addEventListener("beforeunload", function() { debugger; }, false) |
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
# Byte-compiled / optimized / DLL files | |
__pycache__/ | |
*.py[cod] | |
*$py.class | |
# C extensions | |
*.so | |
# Distribution / packaging | |
.Python |
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
LOG_DIR = os.path.join(BASE_DIR, 'logs') # the log dir | |
os.makedirs(LOG_DIR, exist_ok=True) # check to see if we have the directory, if not, create it. | |
LOGGING = { | |
"version": 1, | |
"disable_existing_loggers": False, | |
"formatters": { | |
"simple": { | |
"format": "%(levelname)s %(asctime)s %(message)s" | |
}, |
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
# Byte-compiled / optimized / DLL files | |
__pycache__/ | |
*.py[cod] | |
*$py.class | |
# C extensions | |
*.so | |
# Distribution / packaging |
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
''' Exporta planilhas em Excel ''' | |
from datetime import datetime | |
import django_excel as excel | |
from django.http import HttpResponseBadRequest | |
from .models import Person | |
MDATA = datetime.now().strftime('%Y-%m-%d') | |
def export_data_person(request, atype): |
NewerOlder