def clean_course(self): slug = self.cleaned_data['course'] course = drupal.get_course(slug, full=True) if not course: raise forms.ValidationError( _('There is no course with this short name on the archive.')) return course
def clean_course(self): slug = self.cleaned_data["course"] course = drupal.get_course(slug, full=True) if not course: raise forms.ValidationError(_("There is no course with this short name on the old p2pu site.")) if self.school and course["school"] != self.school: raise forms.ValidationError(_("The %s course was not part of this school.") % data["name"]) return course
def clean_course(self): slug = self.cleaned_data['course'] course = drupal.get_course(slug, full=True) if not course: raise forms.ValidationError(_('There is no course with this short name on the old p2pu site.')) if self.school and course['school'] != self.school: raise forms.ValidationError(_('The %s course was not part of this school.') % data['name']) return course
def clean_course(self): slug = self.cleaned_data['course'] course = drupal.get_course(slug, full=True) if not course: raise forms.ValidationError( _('There is no course with this short name on the old p2pu site.' )) if self.school and course['school'] != self.school: raise forms.ValidationError( _('The %s course was not part of this school.') % data['name']) return course
def sidebar(context): user = context['user'] project = context['project'] is_participating = is_following = is_organizing = False pending_signup = None if user.is_authenticated(): is_participating = project.participants().filter(user=user).exists() profile = user.get_profile() is_following = profile.is_following(project) is_organizing = project.organizers().filter(user=user).exists() if not is_participating and not is_organizing: signup = Page.objects.get(slug='sign-up', project=project) answers = signup.comments.filter(reply_to__isnull=True, deleted=False, author=profile) if answers.exists(): pending_signup = answers[0] participants_count = project.non_organizer_participants().count() followers_count = project.non_participant_followers().count() organizers_count = project.organizers().count() update_count = project.activities().count() content_pages = Page.objects.filter(project__pk=project.pk, listed=True, deleted=False).order_by('index') links = project.link_set.all().order_by('index') school = project.school if school and school.declined.filter(id=project.id).exists(): school = None imported_from = drupal.get_course( project.imported_from) if project.imported_from else None context.update({ 'participating': is_participating, 'participants_count': participants_count, 'following': is_following, 'followers_count': followers_count, 'organizing': is_organizing, 'organizers_count': organizers_count, 'update_count': update_count, 'content_pages': content_pages, 'links': links, 'school': school, 'imported_from': imported_from, 'pending_signup': pending_signup, }) return context
def sidebar(context): user = context['user'] project = context['project'] is_participating = is_following = is_organizing = False pending_signup = None if user.is_authenticated(): is_participating = project.participants().filter(user=user).exists() profile = user.get_profile() is_following = profile.is_following(project) is_organizing = project.organizers().filter(user=user).exists() if not is_participating and not is_organizing: signup = Page.objects.get(slug='sign-up', project=project) answers = signup.comments.filter(reply_to__isnull=True, deleted=False, author=profile) if answers.exists(): pending_signup = answers[0] participants_count = project.non_organizer_participants().count() followers_count = project.non_participant_followers().count() organizers_count = project.organizers().count() update_count = project.activities().count() pending_applicants_count = len(project.pending_applicants()) content_pages = Page.objects.filter(project__pk=project.pk, listed=True, deleted=False).order_by('index') links = project.link_set.all().order_by('index') school = project.school if school and school.declined.filter(id=project.id).exists(): school = None imported_from = drupal.get_course(project.imported_from) if project.imported_from else None context.update({ 'participating': is_participating, 'participants_count': participants_count, 'following': is_following, 'followers_count': followers_count, 'organizing': is_organizing, 'organizers_count': organizers_count, 'update_count': update_count, 'pending_applicants_count': pending_applicants_count, 'content_pages': content_pages, 'links': links, 'school': school, 'imported_from': imported_from, 'pending_signup': pending_signup, }) return context
def sidebar(context): user = context['user'] project = context['project'] sign_up = Signup.objects.get(project=project) is_participating = is_following = is_organizing = False if user.is_authenticated(): is_participating = project.participants().filter(user=user).exists() profile = user.get_profile() is_following = profile.is_following(project) is_organizing = project.organizers().filter(user=user).exists() tags = project.tags.exclude(slug='').order_by('name') organizers = project.organizers() organizers_count = organizers.count() participants = project.non_organizer_participants() participants_count = participants.count() followers = project.non_participant_followers() followers_count = followers.count() update_count = project.activities().count() pending_signup_answers_count = sign_up.pending_answers().count() content_pages = Page.objects.filter(project__pk=project.pk, listed=True, deleted=False).order_by('index') links = project.link_set.all().order_by('index') school = project.accepted_school() imported_from = None if project.imported_from: imported_from = drupal.get_course(project.imported_from) can_add_task = is_organizing if project.category == Project.STUDY_GROUP: can_add_task = is_participating can_change_order = can_add_task chat = '#p2pu-%s-%s' % (project.id, project.slug[:10]) submission_enabled_badges = project.get_submission_enabled_badges() context.update({ 'participating': is_participating, 'participants_count': participants_count, 'following': is_following, 'followers_count': followers_count, 'tags': tags, 'organizing': is_organizing, 'organizers_count': organizers_count, 'update_count': update_count, 'pending_signup_answers_count': pending_signup_answers_count, 'content_pages': content_pages, 'links': links, 'school': school, 'imported_from': imported_from, 'sign_up': sign_up, 'can_add_task': can_add_task, 'can_change_order': can_change_order, 'chat': chat, 'discussion_area': context.get('discussion_area', False), 'is_challenge': (project.category == Project.CHALLENGE), 'submission_enabled_badges': submission_enabled_badges, }) return context
def sidebar(context): user = context["user"] project = context["project"] sign_up = Signup.objects.get(project=project) is_participating = is_following = is_organizing = False if user.is_authenticated(): is_participating = project.participants().filter(user=user).exists() profile = user.get_profile() is_following = profile.is_following(project) is_organizing = project.organizers().filter(user=user).exists() tags = project.tags.exclude(slug="").order_by("name") organizers = project.organizers() organizers_count = organizers.count() participants = project.non_organizer_participants() participants_count = participants.count() followers = project.non_participant_followers() followers_count = followers.count() update_count = project.activities().count() pending_signup_answers_count = sign_up.pending_answers().count() content_pages = Page.objects.filter(project__pk=project.pk, listed=True, deleted=False).order_by("index") links = project.link_set.all().order_by("index") school = project.accepted_school() imported_from = None if project.imported_from: imported_from = drupal.get_course(project.imported_from) can_add_task = is_organizing if project.category == Project.STUDY_GROUP: can_add_task = is_participating can_change_order = can_add_task chat = "#p2pu-%s-%s" % (project.id, project.slug[:10]) peer_skill_badges = project.get_project_badges(only_peer_skill=True) context.update( { "participating": is_participating, "participants_count": participants_count, "following": is_following, "followers_count": followers_count, "tags": tags, "organizing": is_organizing, "organizers_count": organizers_count, "update_count": update_count, "pending_signup_answers_count": pending_signup_answers_count, "content_pages": content_pages, "links": links, "school": school, "imported_from": imported_from, "sign_up": sign_up, "can_add_task": can_add_task, "can_change_order": can_change_order, "chat": chat, "discussion_area": context.get("discussion_area", False), "is_challenge": (project.category == Project.CHALLENGE), "peer_skill_badges": peer_skill_badges, } ) return context
def sidebar(context, max_people_count=64): user = context['user'] project = context['project'] sign_up = Signup.objects.get(project=project) is_participating = is_following = is_organizing = False if user.is_authenticated(): is_participating = project.participants().filter(user=user).exists() profile = user.get_profile() is_following = profile.is_following(project) is_organizing = project.organizers().filter(user=user).exists() tags = project.tags.exclude(slug='').order_by('name') organizers = project.organizers() organizers_count = organizers.count() participants = project.non_organizer_participants() participants_count = participants.count() followers = project.non_participant_followers() followers_count = followers.count() # only display a subset of the participants and followers. remaining = max_people_count sidebar_organizers = organizers[:remaining] sidebar_participants = [] sidebar_followers = [] remaining -= sidebar_organizers.count() if remaining > 0: sidebar_participants = participants[:remaining] remaining -= sidebar_participants.count() if remaining > 0: sidebar_followers = followers[:remaining] remaining -= sidebar_followers.count() update_count = project.activities().count() pending_signup_answers_count = sign_up.pending_answers().count() content_pages = Page.objects.filter(project__pk=project.pk, listed=True, deleted=False).order_by('index') links = project.link_set.all().order_by('index') school = project.accepted_school() imported_from = None if project.imported_from: imported_from = drupal.get_course(project.imported_from) can_add_task = is_organizing if project.category != Project.COURSE: can_add_task = is_participating can_change_order = can_add_task chat = '#p2pu-%s-%s' % (project.id, project.slug[:10]) context.update({ 'participating': is_participating, 'participants_count': participants_count, 'following': is_following, 'followers_count': followers_count, 'tags': tags, 'organizing': is_organizing, 'organizers_count': organizers_count, 'update_count': update_count, 'pending_signup_answers_count': pending_signup_answers_count, 'content_pages': content_pages, 'links': links, 'school': school, 'imported_from': imported_from, 'sign_up': sign_up, 'sidebar_organizers': sidebar_organizers, 'sidebar_participants': sidebar_participants, 'sidebar_followers': sidebar_followers, 'can_add_task': can_add_task, 'can_change_order': can_change_order, 'chat': chat, }) return context
def sidebar(context, max_people_count=64): user = context['user'] project = context['project'] is_participating = is_following = is_organizing = False pending_signup = None if user.is_authenticated(): is_participating = project.participants().filter(user=user).exists() profile = user.get_profile() is_following = profile.is_following(project) is_organizing = project.organizers().filter(user=user).exists() if not is_participating and not is_organizing: signup = Page.objects.get(slug='sign-up', project=project) answers = signup.comments.filter(reply_to__isnull=True, deleted=False, author=profile) if answers.exists(): pending_signup = answers[0] organizers = project.organizers() organizers_count = organizers.count() participants = project.non_organizer_participants() participants_count = participants.count() followers = project.non_participant_followers() followers_count = followers.count() # only display a subset of the participants and followers. remaining = max_people_count sidebar_organizers = organizers[:remaining] sidebar_participants = [] sidebar_followers = [] remaining -= sidebar_organizers.count() if remaining > 0: sidebar_participants = participants[:remaining] remaining -= sidebar_participants.count() if remaining > 0: sidebar_followers = followers[:remaining] remaining -= sidebar_followers.count() update_count = project.activities().count() pending_applicants_count = len(project.pending_applicants()) content_pages = Page.objects.filter(project__pk=project.pk, listed=True, deleted=False).order_by('index') links = project.link_set.all().order_by('index') school = project.accepted_school() imported_from = None if project.imported_from: imported_from = drupal.get_course(project.imported_from) context.update({ 'participating': is_participating, 'participants_count': participants_count, 'following': is_following, 'followers_count': followers_count, 'organizing': is_organizing, 'organizers_count': organizers_count, 'update_count': update_count, 'pending_applicants_count': pending_applicants_count, 'content_pages': content_pages, 'links': links, 'school': school, 'imported_from': imported_from, 'pending_signup': pending_signup, 'sidebar_organizers': sidebar_organizers, 'sidebar_participants': sidebar_participants, 'sidebar_followers': sidebar_followers, }) return context