Skip to content

Instantly share code, notes, and snippets.

View skolo-online's full-sized avatar

Skolo Online Learning skolo-online

View GitHub Profile
@skolo-online
skolo-online / viewsx.py
Created August 22, 2021 09:13
create invoice part 1 view
@login_required
def createInvoice(request):
#create a blank invoice ....
number = 'INV-'+str(uuid4()).split('-')[1]
newInvoice = Invoice.objects.create(number=number)
newInvoice.save()
inv = Invoice.objects.get(number=number)
return redirect('create-build-invoice', slug=inv.slug)
@skolo-online
skolo-online / invoicing-views.py
Created August 17, 2021 07:52
Django Invoicing app - View function
@login_required
def clients(request):
context = {}
clients = Client.objects.all()
context['clients'] = clients
if request.method == 'GET':
form = ClientForm()
context['form'] = form
return render(request, 'invoice/clients.html', context)
@skolo-online
skolo-online / invoice-views.py
Created August 17, 2021 07:47
Python Django invoicing app - views and decorators
from django.contrib.auth.decorators import user_passes_test
#Anonymous required
def anonymous_required(function=None, redirect_url=None):
if not redirect_url:
redirect_url = 'dashboard'
actual_decorator = user_passes_test(
@skolo-online
skolo-online / invoice-forms.py
Last active August 17, 2021 07:30
Django Forms for Invoicing Application - forms.py
from django import forms
from django.contrib.auth.models import User
from django.forms import widgets
from .models import *
import json
class UserLoginForm(forms.ModelForm):
username = forms.CharField(
@skolo-online
skolo-online / invoice-models.py
Created August 17, 2021 07:18
Invoicing App Model Files
from django.db import models
from django.template.defaultfilters import slugify
from django.utils import timezone
from uuid import uuid4
from django.contrib.auth.models import User
class Client(models.Model):