From 6a65446bfa4e09ceac646cc2eb3d815a4ce9f6bd Mon Sep 17 00:00:00 2001 From: Nikolai R Kristiansen Date: Sun, 2 Aug 2015 23:51:21 +0200 Subject: [PATCH] Minor fixes and TODOs --- apps/kassa/forms.py | 2 +- apps/kassa/templates/kassa/register.html | 10 +++++----- apps/kassa/utils.py | 2 +- apps/kassa/views.py | 8 ++++++++ static/app/scripts/app.js | 4 ++-- static/app/templates/search_result.html | 4 ++-- static/dist/scripts/app.js | 4 ++-- static/dist/scripts/templates.js | 4 ++-- 8 files changed, 23 insertions(+), 15 deletions(-) diff --git a/apps/kassa/forms.py b/apps/kassa/forms.py index a165d80..afb4d05 100644 --- a/apps/kassa/forms.py +++ b/apps/kassa/forms.py @@ -11,6 +11,6 @@ class SearchUserForm(forms.Form): class AddCardForm(forms.Form): - phone_number = PhoneNumberField(widget=forms.TextInput(attrs={'type': 'tel'})) card_number = forms.IntegerField(widget=forms.NumberInput()) + phone_number = PhoneNumberField(widget=forms.TextInput(attrs={'type': 'tel'})) user_id = forms.IntegerField(widget=forms.HiddenInput(), required=False) diff --git a/apps/kassa/templates/kassa/register.html b/apps/kassa/templates/kassa/register.html index 5f00a8e..5941d31 100644 --- a/apps/kassa/templates/kassa/register.html +++ b/apps/kassa/templates/kassa/register.html @@ -5,8 +5,9 @@
{% csrf_token %} -

{% trans "Register card" %}

-

+ {{ add_card_form|bootstrap }}
- {{ add_card_form|bootstrap }}
    -
  • If no existing user with membership can be found, a new membership is registered and tied to a card number.
  • -
  • If an existing user is found without a membership, it is renewed
  • +
  • If an existing user is found without a valid membership, the membership is renewed
  • Registering a card number with a phone number already tied to an existing user, will add the card to that user.
diff --git a/apps/kassa/utils.py b/apps/kassa/utils.py index 218bffa..b01f6c8 100644 --- a/apps/kassa/utils.py +++ b/apps/kassa/utils.py @@ -13,7 +13,7 @@ def tekstmelding_new_card_no_user(card_number, phone_number): 'action': 'new_card_no_user', } - url = '{}kassa/notify-new-card'.format(settings.TEKSTMELDING_API_URL) + url = '{}kassa/new-membership-card'.format(settings.TEKSTMELDING_API_URL) response = requests.post( url, data=json.dumps(payload), diff --git a/apps/kassa/views.py b/apps/kassa/views.py index 2d69d23..d232716 100644 --- a/apps/kassa/views.py +++ b/apps/kassa/views.py @@ -81,6 +81,7 @@ def inside_card_api(request): } if request.method == 'POST': + # TODO: Move this to own method in utils.py, called by register_card_and_membership post_data = json.loads(request.body) payload = { 'card_number': post_data.get('card_number'), @@ -111,6 +112,7 @@ def inside_card_api(request): @login_required def inside_register_api(request): + # TODO: move this to own method in utils.py post_data = json.loads(request.body) payload = { 'apikey': settings.INSIDE_API_KEY, @@ -124,3 +126,9 @@ def inside_register_api(request): response = requests.post(url, data=json.dumps(payload), headers=dict(content_type='application/json')) return JsonResponse(response.json(), status=response.status_code) + + +@login_required() +def register_card_and_membership(request): + # TODO: Call membership and card apis above, depending of what need to be done + pass diff --git a/static/app/scripts/app.js b/static/app/scripts/app.js index 9b5f186..ebaa3e1 100644 --- a/static/app/scripts/app.js +++ b/static/app/scripts/app.js @@ -397,14 +397,14 @@ $(document).ready(function(){ /* Register type */ // FIXME: get from form - // action: 'new_card_no_user', 'update_card', 'renewal' + // action: 'new_card_no_user', 'update_card', 'add_or_renew' if(selectedUser === null) { payload.action = 'new_card_no_user'; } else { if(selectedUser.is_member === '1') { payload.action = 'update_card'; } else { - payload.action = 'renewal'; // Not: could also update card number + payload.action = 'add_or_renew'; // Note: could also update card number } } diff --git a/static/app/templates/search_result.html b/static/app/templates/search_result.html index d97d313..159f645 100644 --- a/static/app/templates/search_result.html +++ b/static/app/templates/search_result.html @@ -29,8 +29,8 @@ {% if not no_user_actions %}