Skip to content

Commit

Permalink
Merge pull request #1076 from xzzy/master2
Browse files Browse the repository at this point in the history
Add Legal Name & Payment Information Page
  • Loading branch information
xzzy authored Jul 3, 2024
2 parents db922c7 + 208e51d commit b9a233b
Show file tree
Hide file tree
Showing 11 changed files with 191 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ledger/accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class EmailUserAdmin(UserAdmin):
)
fieldsets = (
(None, {'fields': ('email',)}),
('Personal info', {'fields': ('first_name', 'last_name','position_title', 'dob', 'identification','identification2','senior_card','senior_card2','title','character_flagged', 'character_comments','manager_name','manager_email', 'phone_number', 'mobile_number','residential_address','postal_address','postal_same_as_residential','billing_address','billing_same_as_residential' )}),
('Personal info', {'fields': ('first_name', 'last_name','legal_first_name', 'legal_last_name','position_title', 'dob','legal_dob', 'identification','identification2','senior_card','senior_card2','title','character_flagged', 'character_comments','manager_name','manager_email', 'phone_number', 'mobile_number','residential_address','postal_address','postal_same_as_residential','billing_address','billing_same_as_residential')}),
('Permissions', {'fields': (
'is_active', 'is_staff', 'is_superuser', 'groups')}),
('Important dates', {'fields': ('last_login', 'date_joined')}),
Expand All @@ -52,7 +52,7 @@ class EmailUserAdmin(UserAdmin):
list_display = ('email', 'first_name', 'last_name', 'is_staff', 'is_dummy')
ordering = ('email',)
search_fields = ('email', 'first_name', 'last_name', 'email')
readonly_fields = ('dummy_email','phone_number', 'mobile_number', 'position_title','manager_email','manager_name','residential_address','postal_address','billing_address',)
readonly_fields = ('dummy_email','phone_number', 'mobile_number', 'position_title','manager_email','manager_name','residential_address','postal_address','billing_address','legal_first_name','legal_last_name','legal_dob')

def is_dummy(self, o):
return o.is_dummy_user
Expand Down
31 changes: 31 additions & 0 deletions ledger/accounts/migrations/0035_auto_20240702_1906.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2024-07-02 11:06
from __future__ import unicode_literals

import django.core.files.storage
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('accounts', '0034_auto_20230506_0018'),
]

operations = [
migrations.AddField(
model_name='emailuser',
name='legal_dob',
field=models.DateField(blank=True, null=True, verbose_name='Legal date of birth'),
),
migrations.AddField(
model_name='emailuser',
name='legal_first_name',
field=models.CharField(blank=True, max_length=128, null=True, verbose_name='Legal Given name(s)'),
),
migrations.AddField(
model_name='emailuser',
name='legal_last_name',
field=models.CharField(blank=True, max_length=128, null=True),
),
]
6 changes: 6 additions & 0 deletions ledger/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ class EmailUser(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(unique=True, blank=False)
first_name = models.CharField(max_length=128, blank=False, verbose_name='Given name(s)')
last_name = models.CharField(max_length=128, blank=False)

legal_first_name = models.CharField(max_length=128, null=True, blank=True, verbose_name='Legal Given name(s)')
legal_last_name = models.CharField(max_length=128, null=True, blank=True)

is_staff = models.BooleanField(
default=False,
help_text='Designates whether the user can log into the admin site.',
Expand All @@ -309,6 +313,8 @@ class EmailUser(AbstractBaseUser, PermissionsMixin):
verbose_name='title', help_text='')
dob = models.DateField(auto_now=False, auto_now_add=False, null=True, blank=False,
verbose_name="date of birth", help_text='')
legal_dob = models.DateField(auto_now=False, auto_now_add=False, null=True, blank=True,
verbose_name="Legal date of birth", help_text='')
phone_number = models.CharField(max_length=50, null=True, blank=True,
verbose_name="phone number", help_text='')
position_title = models.CharField(max_length=100, null=True, blank=True,
Expand Down
2 changes: 1 addition & 1 deletion ledger/accounts/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
]

urlpatterns = [
url(r'^$', views.home, name='home'),
# url(r'^$', views.home, name='home'),
url(r'^done/$', views.done, name='done'),
url(r'^validation-sent/$', views.validation_sent, name='validation_sent'),
url(r'^login-retry/$', views.login_retry, name='login_retry'),
Expand Down
4 changes: 4 additions & 0 deletions ledger/payments/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,7 @@ def difference(self, obj):

discrepancy.allow_tags = True
difference.allow_tags = True

@admin.register(models.PaymentInformationLink)
class PaymentInformationLinkAdmin(admin.ModelAdmin):
list_display = ('title','active','created')
26 changes: 26 additions & 0 deletions ledger/payments/migrations/0034_paymentinformationlink.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2024-07-02 14:25
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('payments', '0033_auto_20240228_1852'),
]

operations = [
migrations.CreateModel(
name='PaymentInformationLink',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=1000)),
('textarea', models.TextField(blank=True, null=True)),
('url', models.CharField(max_length=1000)),
('active', models.BooleanField(default=True)),
('created', models.DateTimeField(auto_now_add=True)),
],
),
]
20 changes: 20 additions & 0 deletions ledger/payments/migrations/0035_auto_20240702_2229.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2024-07-02 14:29
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('payments', '0034_paymentinformationlink'),
]

operations = [
migrations.RenameField(
model_name='paymentinformationlink',
old_name='textarea',
new_name='description',
),
]
17 changes: 17 additions & 0 deletions ledger/payments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from ledger.payments.bpoint.models import BpointTransaction, BpointToken
from ledger.payments.cash.models import CashTransaction
from ledger.accounts.models import EmailUser
from django.core.cache import cache

# Oracle Integration
# ======================================
Expand Down Expand Up @@ -232,3 +233,19 @@ class PaymentTotal(models.Model):
def __str__(self):
return '{} - {}'.format(str(self.oracle_system.system_id),self.settlement_date)



class PaymentInformationLink(models.Model):
title = models.CharField(max_length=1000)
description = models.TextField(blank=True, null=True)
url = models.CharField(max_length=1000)
active = models.BooleanField(default=True)
created = models.DateTimeField(auto_now_add=True)

def __str__(self):
return '{}'.format(str(self.title))

def save(self, *args, **kwargs):
cache.delete('models.PaymentInformationLink.objects.filter(active=True)')
super(PaymentInformationLink, self).save(*args, **kwargs)

48 changes: 48 additions & 0 deletions ledger/templates/ledger/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{% extends "ledgergw/web/base_b5.html" %}
{% block content %}



<br>
<h1>Payment Portal</h1>
<br>
<div class='col-sm-12'>
Welcome to the payment portal for Department of Biodiversity, Conservation and Attractions. To access a payment service please choose from the options below.

</div>
<br>


{% for pa in pil_array %}

<div class="card mb-1" >
<div class='row row-eq-height'>
<div class='col-sm-12'>
<div class="row g-0 row-eq-height">

<div class="col-sm-8">
<div class="card-body">
<h5 class="card-title">{{ pa.title }}</h5>
<p class="card-text">{{ pa.description }}</p>
</div>
</div>
<div class="col-sm-4 text-end ">
<div class='col-sm-12 d-none d-sm-block'>
<a class='mt-4 me-4 btn btn-primary btn-lg' href="{{ pa.url }}">OPEN <i class="bi bi-subtract"></i></a>
</div>
<div class='col-sm-12 d-sm-none d-md-none d-lg-none d-xl-none d-xl-none'>
<div class="d-grid gap-2 p-1">
<a class="btn btn-primary" href="{{ pa.url }}">OPEN <i class="bi bi-subtract"></i></a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endfor %}



{% endblock %}

5 changes: 3 additions & 2 deletions ledger/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from django.contrib import admin
from django.views.generic import TemplateView
from oscar.app import application

from ledger import views

urlpatterns = [
#url(r'^ledger/admin/', admin.site.urls, name='ledger_admin'),
Expand All @@ -26,5 +26,6 @@
url(r'^ledger/', include('social_django.urls', namespace='social')),
url(r'^ledger/checkout/', application.urls),
url(r'^taxonomy/', include('ledger.taxonomy.urls')),
url(r'^$', TemplateView.as_view(template_name='customers/base.html'), name='home')
url(r'^$', views.HomeView.as_view(), name='home'),
# url(r'^$', TemplateView.as_view(template_name='customers/base.html'), name='home')
]
33 changes: 33 additions & 0 deletions ledger/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.auth.models import Group
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.http import HttpResponse, HttpResponseRedirect
from django.views.generic import TemplateView, ListView, DetailView, CreateView, UpdateView, DeleteView, FormView, View
from django.shortcuts import get_object_or_404
from django.core.cache import cache

from ledger.payments import models
import json

class HomeView(TemplateView):
template_name = 'ledger/home.html'

def get_context_data(self, **kwargs):
context = {}
pil_array = []

pil_cache = cache.get('models.PaymentInformationLink.objects.filter(active=True)')

if pil_cache is None:
payment_information_links = models.PaymentInformationLink.objects.filter(active=True)
for pil in payment_information_links:
row = {}
row['title'] = pil.title
row['description'] = pil.description
row['url'] = pil.url
pil_array.append(row)
cache.set('models.PaymentInformationLink.objects.filter(active=True)',json.dumps(pil_array), 86400)
else:
pil_array = json.loads(pil_cache)
context['pil_array'] = pil_array
return context

0 comments on commit b9a233b

Please sign in to comment.