def join(request, club_id): club = get_object_or_404(Club, pk=club_id) context = {'club': club} # Make sure the user isn't already a member! # NOTE: This is only a superficial protection as the user can simply navigate to the form via the form list or URL if is_coordinator_or_member(club, request.user): context['error_message'] = 'already_in' elif get_user_city(request.user) != club.city: context['error_message'] = 'city_error' elif get_user_gender(request.user) != club.gender: context['error_message'] = 'gender_error' # If the club's registration is open, then redirect to the # registration form Otherwise, return a message that registration # is closed if club.registration_is_open(): reg_form = club.get_registration_form() return HttpResponseRedirect(reverse("forms:form_detail", args=(club.id, reg_form.id), current_app=FORMS_CURRENT_APP)) else: context['error_message'] = 'closed_membership' return render(request, 'clubs/join_error.html', context)
def for_user_city(self, user=None): city_condition = models.Q() if user and user.is_authenticated(): city = get_user_city(user) if city: city_condition = models.Q(submitter__common_profile__city=city) return self.filter(city_condition)
def for_user_city(self, user): # Used in indicators city_condition = models.Q() if user and user.is_authenticated(): city = get_user_city(user) if city: city_condition = models.Q(requester__common_profile__city=city) return self.filter(city_condition)
def for_user_city(self, user=None): city_condition = models.Q() if user and user.is_authenticated(): city = get_user_city(user) if city: city_condition = models.Q(coordinator__common_profile__city=city, is_limited_by_city=True) |\ models.Q(is_limited_by_city=False) return self.filter(city_condition)
def for_user_city(self, user=None): city_condition = models.Q() if user: city = get_user_city(user) if city: city_condition = models.Q(city=city) | \ models.Q(city="") return self.filter(city_condition)
def for_user_city(self, user=None): city_condition = models.Q() if user: city = get_user_city(user) if city: city_condition = models.Q(user__common_profile__city=city) return self.filter(city_condition)
def list_colleagues(request): # If the user has the view_colleague_profiles permission, show # colleague_profiles that are pending-revision. if is_arshindi_coordinator_or_deputy(request.user) or \ request.user.has_perm('arshidni.view_colleagueprofile'): user_colleagues = ColleagueProfile.objects.current_year().for_user_city(request.user) city = get_user_city(request.user) # For cities other than Riyadh, we have gender-unspecific # Arshidni (yay). if city == 'R': user_colleagues = user_colleagues.for_user_gender(request.user) available = user_colleagues.available().published() unavailable = user_colleagues.filter(Q(is_available=False) | Q(is_published__isnull=True)) else: user_colleagues = ColleagueProfile.objects.current_year().for_user_gender(request.user).for_user_city(request.user).published() available = user_colleagues.available() unavailable = user_colleagues.unavailable() context = {'available': available, 'unavailable': unavailable} return render(request, 'arshidni/colleague_list.html', context)
def list_colleagues(request): # If the user has the view_colleague_profiles permission, show # colleague_profiles that are pending-revision. if is_arshindi_coordinator_or_deputy(request.user) or \ request.user.has_perm('arshidni.view_colleagueprofile'): user_colleagues = ColleagueProfile.objects.current_year( ).for_user_city(request.user) city = get_user_city(request.user) # For cities other than Riyadh, we have gender-unspecific # Arshidni (yay). if city == 'R': user_colleagues = user_colleagues.for_user_gender(request.user) available = user_colleagues.available().published() unavailable = user_colleagues.filter( Q(is_available=False) | Q(is_published__isnull=True)) else: user_colleagues = ColleagueProfile.objects.current_year( ).for_user_gender(request.user).for_user_city( request.user).published() available = user_colleagues.available() unavailable = user_colleagues.unavailable() context = {'available': available, 'unavailable': unavailable} return render(request, 'arshidni/colleague_list.html', context)
def wrapper(request, *args, **kwargs): if not get_user_city(request.user) in [u'الرياض', '']: return render(request, "studentguide/other-cities.html") return view_func(request, *args, **kwargs)