This file contains hidden or 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 ZipcodeStatesAdmin(admin.ModelAdmin): | |
list_display = ('zipcode', 'count', ) | |
admin.site.register(ZipcodeStats, ZipcodeStatsAdmin) |
This file contains hidden or 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 random import randint | |
from django.db.models import QuerySet | |
from django.http import request | |
from django.views.generic.base import View | |
from django.http import HttpResponse | |
import os | |
from zipfile import ZipFile | |
from .generate import Generate | |
from django.db.utils import DEFAULT_DB_ALIAS | |
from django.contrib.admin.utils import NestedObjects |
This file contains hidden or 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 Csv(GenerateCSVMixin): | |
custom_headers = [(h.column) for h in Sales._meta.get_fields()] | |
queryset = Sales.objects.filter(id=27) | |
custom_queryset = queryset | |
class Csv(GenerateCSVMixin): | |
model = Sales | |
download_file = True |
This file contains hidden or 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.views.generic.base import View | |
from django.http import HttpResponse | |
import os | |
from .generate import Generate | |
class GenerateCSV(Generate): | |
model = None | |
download = False |
This file contains hidden or 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 Csv(View): | |
def get(self, request): | |
sales = Sales.objects.all() | |
headers = [(h.column) for h in Sales._meta.get_fields()] | |
csv_array = Generate(request).csv_file(headers=headers, data=sales) | |
if os.path.exists(csv_array[1]): | |
with open(csv_array[1], 'r') as csv: | |
response = HttpResponse(csv.read(), content_type="text/csv") | |
response["Content-Disposition"] = f'attachment; filename={csv_array[0]}' |
This file contains hidden or 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 Csv(View): | |
def get(self, request): | |
sales = Sales.objects.all() | |
headers = [(h.column) for h in Sales._meta.get_fields()] | |
csv_array = Generate(request).csv_file(headers=headers, data=sales) | |
return HttpResponse(f'{csv_array[0]}') |
This file contains hidden or 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.http import request as Request | |
from django.db.models.query import QuerySet | |
from django.forms.models import model_to_dict | |
from random import randint | |
import os | |
import csv | |
class Generate: |
This file contains hidden or 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 ReportRequest(models.Model): | |
host = models.CharField(max_length=1000) | |
path = models.CharField(max_length=1000) | |
method = models.CharField(max_length=50) | |
uri = models.CharField(max_length=2000) | |
status_code = models.IntegerField() | |
remote_addr = models.IPAddressField() | |
remote_addr_fwd = models.IPAddressField(blank=True, null=True) | |
request_meta = models.TextField() | |
query = models.TextField() |
This file contains hidden or 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.views.generic.base import View | |
from django.http import HttpResponse | |
from .render import Render | |
class RenderPDF(Render): | |
params: dict = None | |
template: str = None | |
email: bool = False |
This file contains hidden or 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.views.generic import View | |
from django.utils import timezone | |
from .models import * | |
from .render import * | |
import requests | |
from threading import Thread, activeCount | |
def send_email(file: list): | |
r = requests.post( |