Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Features #9

Merged
merged 3 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,4 @@ manage.py
# Ignore all migrations files except __init__.py
**/migrations/*
!**/migrations/__init__.py
bandit_report.txt
bandit_report.txt
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ sphinx:
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: packages/requirements-dev.txt
- requirements: packages/requirements-dev.txt
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ INSTALLED_APPS = [
]
MODEL_PREFIX = "invoice"
MODEL_TEMPLATE = "sage_invoice"
```
```
912 changes: 825 additions & 87 deletions packages/requirements-dev.txt

Large diffs are not rendered by default.

309 changes: 294 additions & 15 deletions packages/requirements.txt

Large diffs are not rendered by default.

112 changes: 102 additions & 10 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ packages = [
[tool.poetry.dependencies]
python = ">=3.8,<4.0"
django = [
{ version = ">=4.2,<5.0", python = ">=3.8,<3.10"},
{ version = ">=4.2,<5.0", python = ">=3.8,<3.10"},
{ version = ">=4.2,<5.3", python = ">=3.10" } # Django 4.2 and 5.x for Python 3.10+
]
jinja2 = "^3.1.4"
pillow = "^10.4.0"
django-sage-tools = "^0.2.2"
django-import-export = "^4.1.1"

[tool.poetry.group.dev.dependencies]
black = "^24.4.2"
Expand All @@ -34,14 +35,16 @@ codecov = "^2.1.13"
ruff = "^0.5.7"
commitizen = "^3.29.0"
pytest-django = "^4.8.0"
pylint-django = "^2.5.5"

bandit = {extras = ["toml"], version = "^1.7.9"}

[tool.poetry.extras]
docs = ["sphinx", "sphinx-autobuild", "sphinx-rtd-theme"]

[tool.pytest.ini_options]
addopts = "--cov --cov-report=term-missing --cov-report=html --cov-fail-under=90"
DJANGO_SETTINGS_MODULE = "kerenl.settings"
DJANGO_SETTINGS_MODULE = "kernel.settings"
python_files = ["tests.py", "test_*.py"]
testpaths = ["tests"]
norecursedirs = [
Expand Down Expand Up @@ -208,4 +211,4 @@ module-rgx = "(([a-z_][a-z0-9_]*)|(__.*__))$"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
build-backend = "poetry.core.masonry.api"
2 changes: 1 addition & 1 deletion sage_invoice/admin/actions/download_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def export_as_html(modeladmin, request, queryset):

for static_path, archive_path in static_files.items():
absolute_static_path = os.path.join(
settings.BASE_DIR, "media", "static", static_path
settings.BASE_DIR, "sage_invoice", "static", static_path
)
if os.path.exists(absolute_static_path):
with open(absolute_static_path, "rb") as static_file:
Expand Down
100 changes: 56 additions & 44 deletions sage_invoice/admin/invoice.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from django.contrib import admin
from django.utils.translation import gettext_lazy as _
from import_export.admin import ImportExportModelAdmin

from sage_invoice.admin.actions import export_as_html, show_invoice
from sage_invoice.models import Invoice, InvoiceColumn, InvoiceItem, InvoiceTotal
from sage_invoice.resource import InvoiceResource


class InvoiceItemInline(admin.TabularInline):
Expand All @@ -23,7 +25,8 @@ class InvoiceTotalInline(admin.TabularInline):


@admin.register(Invoice)
class InvoiceAdmin(admin.ModelAdmin):
class InvoiceAdmin(ImportExportModelAdmin, admin.ModelAdmin):
resource_class = InvoiceResource
admin_priority = 1
list_display = ("title", "invoice_date", "customer_name", "status")
search_fields = ("customer_name", "status", "customer_email")
Expand All @@ -34,49 +37,58 @@ class InvoiceAdmin(admin.ModelAdmin):
readonly_fields = ("slug",)
actions = [export_as_html, show_invoice]

fieldsets = (
(
_("Invoice Details"),
{
"fields": (
"title",
"slug",
"invoice_date",
"tracking_code",
"due_date",
"customer_name",
"customer_email",
"category",
),
"description": _(
"Basic details of the invoice including title, date, and customer information."
),
},
),
(
_("Status & Notes"),
{
"fields": ("status", "notes"),
"description": _(
"Current status of the invoice and any additional notes."
),
},
),
(
_("Design Elements"),
{
"fields": (
"logo",
"signature",
"stamp",
"template_choice",
),
"description": _(
"Design-related elements like logo, and template choice."
),
},
),
)
class Media:
js = ("assets/js/invoice_admin.js",)

def get_fieldsets(self, request, obj=None):
fieldsets = (
(
_("Invoice Details"),
{
"fields": (
"title",
"slug",
"invoice_date",
"tracking_code",
"due_date",
"customer_name",
"customer_email",
"category",
"receipt",
),
"description": _(
"Basic details of the invoice including title, date, and customer information."
),
},
),
(
_("Status & Notes"),
{
"fields": ("status", "notes"),
"description": _(
"Current status of the invoice and any additional notes."
),
},
),
)
fieldsets += (
(
_("Design Elements"),
{
"fields": (
"logo",
"signature",
"stamp",
"template_choice",
),
"description": _(
"Design-related elements like logo, and template choice."
),
},
),
)

return fieldsets

inlines = [InvoiceItemInline, InvoiceColumnInline, InvoiceTotalInline]

Expand Down
1 change: 1 addition & 0 deletions sage_invoice/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ class InvoiceConfig(AppConfig):

def ready(self) -> None:
import sage_invoice.check
import sage_invoice.signals
Loading
Loading