Skip to content

Commit

Permalink
updated profile.days_used to also return number of billable days
Browse files Browse the repository at this point in the history
  • Loading branch information
jsayles committed Jul 14, 2017
1 parent 1562125 commit b28a32e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
3 changes: 3 additions & 0 deletions member/templates/member/profile/profile_activity.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ <h3>
<h3>
Activity This Period:
{{ days_this_period | length}} {% if allowance %} of {{ allowance }} Days{% endif %}
{% if days_this_period != billable %}
({{ billable }} billable)
{% endif %}
</h3>

{% if days_this_period %}
Expand Down
6 changes: 4 additions & 2 deletions member/views/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def profile_activity(request, username):
membership = Membership.objects.for_user(user)
period_start, period_end = membership.get_period()
days_this_period = membership.coworking_days_in_period()
allowance = membership.allowance_by_resource(Resource.objects.day_resource)
days, allowance, billable = user.profile.days_used()
show_user = False
show_paid = False
for d in days_this_period:
Expand All @@ -127,7 +127,9 @@ def profile_activity(request, username):
'show_user': show_user,
'show_paid': show_paid,
'days_this_period': days_this_period,
'allowance': allowance
'allowance': allowance,
'billable': billable,

}
return render(request, 'member/profile/profile_activity.html', context)

Expand Down
5 changes: 3 additions & 2 deletions nadine/models/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,10 @@ def pay_bills_form(self):

def days_used(self, target_date=None):
membership = Membership.objects.for_user(self.user, target_date)
days = membership.coworking_days_in_period(target_date).count()
days = membership.coworking_days_in_period(target_date)
billable = days.filter(payment="Bill")
allowed = membership.coworking_day_allowance(target_date)
return (days, allowed)
return (days.count(), allowed, billable.count())

def all_emails(self):
# Done in two queries so that the primary email address is always on top.
Expand Down
2 changes: 1 addition & 1 deletion tablet/templates/tablet/user_profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h4 style="color:red;">Check with {{ site.name }} staff about these required act
<h3>Billing Day: <span style="font-weight:normal;">{{ user.membership.bill_day_str }}</span></h3>

<h3>Visits This Period:
<span style="font-weight:normal;">{{ days_this_period }}
<span style="font-weight:normal;">{{ billable }}
{% if day_allowance %}
of {{ day_allowance }}
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion tablet/templates/tablet/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div style="font-weight:bold; padding:1em; font-size:200%">
As of today, you have used
<span style="color: {{ usage_color }}">
{{ days_this_period }} {% if day_allowance %} of {{ day_allowance }} {% endif %}
{{ billable }} {% if day_allowance %} of {{ day_allowance }} {% endif %}
</span>
days.

Expand Down
6 changes: 4 additions & 2 deletions tablet/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def user_profile(request, username):
previous_hosts = User.helper.active_members().filter(id__in=guest_days)

# Pull up how many days were used this period
days, allowed = user.profile.days_used()
days, allowed, billable = user.profile.days_used()

# Pull our open alerts
alert_list = [MemberAlert.MEMBER_AGREEMENT, MemberAlert.TAKE_PHOTO, MemberAlert.ORIENTATION, MemberAlert.KEY_AGREEMENT, MemberAlert.ASSIGN_CABINET, MemberAlert.ASSIGN_MAILBOX, MemberAlert.RETURN_DOOR_KEY, MemberAlert.RETURN_DESK_KEY]
Expand All @@ -109,6 +109,7 @@ def user_profile(request, username):
'can_signin': can_signin,
'days_this_period': days,
'day_allowance': allowed,
'billable': billable,
'previous_hosts' :previous_hosts,
'open_alerts': open_alerts,
'member_search_form': member_search_form,
Expand Down Expand Up @@ -166,7 +167,7 @@ def signin_user_guest(request, username, paid_by):
def welcome(request, username):
usage_color = "black"
user = get_object_or_404(User, username=username)
days, allowed = user.profile.days_used()
days, allowed, billable = user.profile.days_used()
if days > allowed:
usage_color = "red"
elif days == allowed:
Expand All @@ -179,6 +180,7 @@ def welcome(request, username):
'user': user,
'days_this_period': days,
'day_allowance': allowed,
'billable': billable,
'usage_color': usage_color,
'bill_day_str':bill_day_str,
'motd': motd,
Expand Down

0 comments on commit b28a32e

Please sign in to comment.