def view(request, venue_id): venue = Venue.objects.get(pk=venue_id) if request.method == "POST": venue.name = request.POST.get('name', '') venue.aka_name = request.POST.get('aka_name', '') venue.save() role = request.current_role splitted_address = venue.medical_address.split(', ') medical_address = { 'address': splitted_address.pop(0) if splitted_address else '', 'city': splitted_address.pop(0) if splitted_address else '', 'state': splitted_address.pop(0) if splitted_address else '', 'zip': splitted_address.pop(0) if splitted_address else '' } try: student = Student.objects.get(id=role.entity.id) except Student.DoesNotExist: student = False except TypeError: student = False except AttributeError: student = False is_recipient = VenueRecipient.objects.filter(groundskeeper=student) rent_venue_url = False can_edit = request.user.is_authenticated() and ( venue.is_groundskeeper(role) or venue.is_renter(role)) if venue.is_available() and not venue.is_renter(role): rent_venue_url = get_rent_venue_cbui_url(venue) sponsor = venue.renter sponsor_info = False if sponsor: if sponsor.name != "": sponsor_info = True venue_spuds = SpudsController.GetSpudsForVenue(venue) teams = [ team.team_page for team in TeamVenueAssociation.objects.filter(venue=venue) ] return render( request, 'spuddercern/pages/venues_view.html', { 'venue': venue, 'teams': teams, 'medical_address': medical_address, 'is_recipient': is_recipient, 'rent_venue_url': rent_venue_url, 'sponsor': sponsor, 'sponsor_info': sponsor_info, 'is_sponsor': venue.is_renter(role), 'student': student, 'venue_spuds': venue_spuds, 'base_url': 'spuddercern/base.html' })