Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for bug where needed count is sometimes incorrect in jobs sidebar #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion signup/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Coordinator(models.Model):
url = URLField()

class Job(models.Model):
'''An individual job'''
'''An individual job (volunteer shift) in a role'''

id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
source = ForeignKey(Source, on_delete=models.CASCADE)
Expand Down Expand Up @@ -116,4 +116,5 @@ class Meta :
# ---

comment = TextField()


4 changes: 2 additions & 2 deletions signup/templates/signup/jobpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<li class="list-group-item">
<img title="{{r.alt}}" src="{% static r.pic %}" height=20></img>
<a href="{% url "jobs" title=r.role.source.pk %}">{{r.role.source.pk}}</a>
<br/><small>{{r.needed}} volunteer(s) needed</small>
<br/><small>{{r.needed}} volunteer(s) needed </small>
</li>
{% endif %}
{% endfor %}
Expand Down Expand Up @@ -48,7 +48,7 @@
<a href="{% url "jobs" title=r.role.source.pk %}">
<img src="{% static r.pic %}" height=15></img>
{{r.role.source.pk}}
<br/><small>{{r.needed}} volunteer(s) needed</small>
<br/><small>{{r.needed}} volunteer(s) needed </small>
</a>
</li>
{% endif %}
Expand Down
8 changes: 4 additions & 4 deletions signup/views/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def getNavData() :
jobcount = 0

personcount = Volunteer.objects.filter(source__exact=role.source.pk).count()
ent['needed'] = jobcount - personcount
ent['needed'] = jobcount - personcount # sometimes incorrect, theories above
ent['jobs'] = jobcount
ent['status'] = role.status
ent.update(badgeFor(role, jobcount, personcount))
Expand Down Expand Up @@ -189,13 +189,13 @@ def jobs(request, title):
status = get_status(role, needed_staff, total_staff)

template_values = {
'navdata': navdata,
'navdata': navdata, # .needed is sometimes incorrect
'role': role,
'coordinators' : coordinators,
'jobs' : jobstaff,
'user' : request.user,
'total' : total_staff,
'needed' : needed_staff,
'total' : total_staff, # correct
'needed' : needed_staff, # correct
'status' : status,
'coordinator_of' : is_coordinator,
'next' : next_job,
Expand Down
3 changes: 2 additions & 1 deletion signup/views/react.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ def get_job_summary(request) :
jobcount = Job.objects.filter(source__exact=role.source.pk).aggregate(Sum('needs'))['needs__sum']
if jobcount is None :
jobcount = 0
# may need to update personcount here like in getNavData()
personcount = Volunteer.objects.filter(source__exact=role.source.pk).count()
navdata.append({
'role': role.pk,
'needed': jobcount - personcount,
'needed': jobcount - personcount,
'jobs': jobcount,
'status': role.status,
'is_coordinator': is_coordinator_of(request.user, role.source)
Expand Down