Skip to content

Commit

Permalink
Rewrite logic and abstraction
Browse files Browse the repository at this point in the history
  • Loading branch information
henryk committed Apr 19, 2022
1 parent a45d78b commit e765e83
Show file tree
Hide file tree
Showing 7 changed files with 422 additions and 144 deletions.
12 changes: 0 additions & 12 deletions byro_fints/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@
class PinRequestForm(forms.Form):
form_name = _("PIN request")
login_name = forms.CharField(label=_("Login name"), required=True)
pin = forms.CharField(
label=_("PIN"), widget=forms.PasswordInput(render_value=True), required=True
)
store_pin = forms.ChoiceField(
label=_("Store PIN?"),
choices=[
["0", _("Don't store PIN")],
["1", _("For this login session only")],
["2", _("Store PIN (encrypted with account password)")],
],
initial="0",
)


class LoginCreateStep1Form(PinRequestForm):
Expand Down
32 changes: 31 additions & 1 deletion byro_fints/templates/byro_fints/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
{% endblocktrans %}</p>
<p><a class="btn btn-success" href="{% url "plugins:byro_fints:finance.fints.login.add" %}"><span class="fa fa-plus"></span> {% trans "Create bank login" %}</a></p>

<h4>{% trans "Known bank logins" %}</h4>
{% if fints_logins %}
<h4>{% trans "Bank logins that have been fully set up" %}</h4>
<table class="table table-sm">
<thead>
<tr>
Expand Down Expand Up @@ -51,6 +52,35 @@ <h4>{% trans "Known bank logins" %}</h4>
{% endfor %}
</tbody>
</table>
{% endif %}

{% if inactive_logins %}
<h4>{% trans "Other bank logins" %}</h4>
<table class="table table-sm">
<thead>
<tr>
<th class="table-column-small">{% trans "BLZ" %}</th>
<th class="table-column-large">{% trans "Name" %}</th>
<th class="table-column-large">{% trans "FinTS URL" %}</th>
<th>{% trans "Actions" %}</th>
</tr>
</thead>
<tbody>
{% for login in inactive_logins %}
<tr>
<td>{{ login.blz }}</td>
<td>{{ login.name }}</td>
<td>{{ login.fints_url }}</td>
<td>
<a href="{% url "plugins:byro_fints:finance.fints.login.add" %}?login={{ login.pk }}" class="btn btn-success">
<span class="fa fa-plus" title="{% trans "Finish setting up login" %}"></span><span class="sr-only">{% trans "Set up login" %}</span>
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}

<h4>{% trans "Known bank accounts" %}</h4>
{% include "byro_fints/snippet_account_list.html" with account_list=fints_accounts %}
Expand Down
10 changes: 7 additions & 3 deletions byro_fints/views/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from .account import (
FinTSAccountFetchView, FinTSAccountInformationView, FinTSAccountLinkView,
FinTSAccountFetchView,
FinTSAccountInformationView,
FinTSAccountLinkView,
)
from .dashboard import Dashboard
from .login import FinTSLoginEditView, FinTSLoginRefreshView
from .login_add import (
FinTSLoginCreateStep1View, FinTSLoginCreateStep2View,
FinTSLoginCreateStep3View, FinTSLoginCreateStep4View,
FinTSLoginCreateStep1View,
FinTSLoginCreateStep2View,
FinTSLoginCreateStep3View,
FinTSLoginCreateStep4View,
FinTSLoginCreateStep5View,
)
from .transfer import FinTSAccountTransferView, FinTSLoginTANRequestView
5 changes: 4 additions & 1 deletion byro_fints/views/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
from django.views.generic.edit import FormMixin
from django_securebox.utils import Storage
from fints.client import (
FinTS3PinTanClient, FinTSClientMode, NeedTANResponse, ResponseStatus,
FinTS3PinTanClient,
FinTSClientMode,
NeedTANResponse,
ResponseStatus,
)
from fints.exceptions import FinTSClientPINError
from fints.formals import TANMedia5
Expand Down
14 changes: 13 additions & 1 deletion byro_fints/views/dashboard.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
from django.views.generic import ListView

from ..models import FinTSAccount, FinTSLogin
from ..models import FinTSAccount, FinTSLogin, FinTSUserLogin


class Dashboard(ListView):
template_name = "byro_fints/dashboard.html"
queryset = FinTSLogin.objects.order_by("blz").all()
context_object_name = "fints_logins"

def get_queryset(self):
return (
super()
.get_queryset()
.filter(
user_login__in=FinTSUserLogin.objects.filter(user=self.request.user)
)
)

def get_context_data(self, *args, **kwargs):
context = super().get_context_data(*args, **kwargs)
context["fints_accounts"] = FinTSAccount.objects.order_by("iban").all()
context["inactive_logins"] = (
super().get_queryset().exclude(pk__in=self.get_queryset())
)
return context
Loading

0 comments on commit e765e83

Please sign in to comment.