-
Notifications
You must be signed in to change notification settings - Fork 36
Network balance limit (Client dependent) #38
base: master
Are you sure you want to change the base?
Network balance limit (Client dependent) #38
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks! If you are contributing on behalf of someone else (eg your employer): the individual CLA is not sufficient - use https://developers.facebook.com/opensource/cla?type=company instead. Contact [email protected] if you have any questions. |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
@shivkumarsah updated the pull request - view changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Some small changes.
"""Crispy form to set Network balance limit and transaction. | ||
set min_value =0.01 so that it will not accept 0 value""" | ||
|
||
limit = forms.CharField(required=False, label="Maximum Balance Limit", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More clear name like max_balalance
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments incorporated in commit id :1e5832b491ca904b5fd002d9d61f3d1fca09cbcf
|
||
limit = forms.CharField(required=False, label="Maximum Balance Limit", | ||
max_length=10) | ||
transaction = forms.CharField(required=False, max_length=3, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max_transfer_attempts
or max_unsuccessful_transfers
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments incorporated in commit id :1e5832b491ca904b5fd002d9d61f3d1fca09cbcf
cloud/endagaweb/models.py
Outdated
@@ -978,6 +978,9 @@ class Network(models.Model): | |||
# Network environments let you specify things like "prod", "test", "dev", | |||
# etc so they can be filtered out of alerts. For internal use. | |||
environment = models.TextField(default="default") | |||
# Added for Network Balance Limit | |||
max_account_limit = models.BigIntegerField(default=10000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should mention balance max_balance
maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments incorporated in commit id :1e5832b491ca904b5fd002d9d61f3d1fca09cbcf
cloud/endagaweb/models.py
Outdated
@@ -978,6 +978,9 @@ class Network(models.Model): | |||
# Network environments let you specify things like "prod", "test", "dev", | |||
# etc so they can be filtered out of alerts. For internal use. | |||
environment = models.TextField(default="default") | |||
# Added for Network Balance Limit | |||
max_account_limit = models.BigIntegerField(default=10000) | |||
max_failure_transaction = models.IntegerField(default=3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this specific to all transactions or transfers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes this network max balance limit applied to network.If any transaction happen for subscriber of same network this is applied on them
{% block js %} | ||
|
||
<script type="text/javascript" | ||
src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check your jquery version matches the rest of the site. Try to use the same CDN if possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep changes local to the PR. This will result in merge conflicts
cloud/endagaweb/views/dashboard.py
Outdated
@@ -560,6 +560,9 @@ def post(self, request, imsi=None): | |||
CURRENCIES[currency]).amount_raw | |||
if abs(amount) > 2147483647: | |||
raise ValueError(error_text) | |||
if sub.balance + amount > network.max_account_limit: | |||
error_text = 'Error : Crossed Credit Limit.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Print out the max limit in the error message? Also check your units. I am pretty sure sub.balance
is actually in millicents/pesos depending on the currency selected. Testing this in USD is a good idea. Also can we write tests for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cloud/endagaweb/views/network.py
Outdated
CURRENCIES[currency]).amount_raw | ||
validity_days = int(request.POST.get('validity_days')) or 0 | ||
if validity_days > 10000: | ||
validity_days = 10000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: Raise an error rather than forcing a maximum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please incorporate the change into this review
cloud/endagaweb/views/network.py
Outdated
return redirect(urlresolvers.reverse('network-denominations')) | ||
|
||
user_profile = models.UserProfile.objects.get(user=request.user) | ||
with transaction.atomic(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice :)
cloud/endagaweb/views/network.py
Outdated
|
||
if request.POST.get('transaction') == "" and request.POST.get( | ||
'limit') == "": | ||
error_text = 'Error : please provide value.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just saying you can do a lot of these checks in subclasses of forms.Form
and raise forms.ValidationError
cloud/endagaweb/models.py
Outdated
|
||
def __unicode__(self): | ||
return "Amount %s - %d for %s(days)" % ( | ||
self.start_amount, self.end_amount, self.validity_days) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: humanize_credits on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please dont open new PRs for fixes to existing PRs its difficult to keep track of changes this way
Careful to split out reviews. I think this also contained #39 |
@shivkumarsah updated the pull request - view changes |
@shivkumarsah updated the pull request - view changes |
@shivkumarsah updated the pull request - view changes |
is this ready for review? |
yes , please review.As suggested comments are incorporated. |
{% block js %} | ||
|
||
<script type="text/javascript" | ||
src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep changes local to the PR. This will result in merge conflicts
cloud/endagaweb/views/dashboard.py
Outdated
if abs(amount) > 2147483647: | ||
raise ValueError(error_text) | ||
if (sub.balance + amount) > network.max_balance: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we wanted to disable this check of the operator UI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will implement this on the client
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed.fixed in commit id :# 07e0730
cloud/endagaweb/views/network.py
Outdated
CURRENCIES[currency]).amount_raw | ||
validity_days = int(request.POST.get('validity_days')) or 0 | ||
if validity_days > 10000: | ||
validity_days = 10000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please incorporate the change into this review
<a href=" | ||
{% if active_tab == 'limit' %} # | ||
#{% else %}{% url 'network_balance_limit' %} | ||
{% endif %}">Limit</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename this to Security/Safety
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments incorporated with commit id:# 07e0730
@@ -0,0 +1,305 @@ | |||
{% extends "dashboard/layout.html" %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per our phone call, lets make the denominations a continuous range?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will be fixed as part of sprint 5
…nce limit,Unsuccessful transactions and denomination brackets,disable max balance check of the operator UI and made denomination changes
@shivkumarsah updated the pull request - view changes |
@shivkumarsah updated the pull request - view changes |
@9muir has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@shivkumarsah updated the pull request - view changes - changes since last import |
@9muir has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Please review network/subscriber credit limit implementation which include the below features: