Skip to content

Commit

Permalink
Merge pull request #18 from np5/machine_detail_via_serial
Browse files Browse the repository at this point in the history
Make machine_detail view work with id or serial
  • Loading branch information
grahamgilbert committed Oct 11, 2015
2 parents 13aa553 + 452efab commit 0026b05
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions server/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,10 +810,13 @@ def new_machine(request, group_id):
# Machine detail
@login_required
def machine_detail(request, machine_id):
# check the user is in a BU that's allowed to see this Machine
machine = get_object_or_404(Machine, pk=machine_id)
try:
machine = Machine.objects.get(pk=machine_id)
except (ValueError, Machine.DoesNotExist):
machine = get_object_or_404(Machine, serial=machine_id)
machine_group = machine.machine_group
business_unit = machine_group.business_unit
# check the user is in a BU that's allowed to see this Machine
user = request.user
user_level = user.userprofile.level
if business_unit not in user.businessunit_set.all():
Expand Down

0 comments on commit 0026b05

Please sign in to comment.