-
Notifications
You must be signed in to change notification settings - Fork 64
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
Tags count in view #158
Tags count in view #158
Changes from 2 commits
cf1a76e
2887763
0474e36
b88e3d6
0d2d384
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,10 +83,10 @@ def test_challenge_creation(self): | |
def test_get_listed_projects(self): | ||
deleted_project = Project(deleted=True, test=False) | ||
deleted_project.save() | ||
|
||
not_listed_project = Project(not_listed=True, test=False) | ||
not_listed_project.save() | ||
|
||
under_dev_project = Project(name="under_dev:default", test=False) | ||
under_dev_project.save() | ||
|
||
|
@@ -106,3 +106,61 @@ def test_get_listed_projects(self): | |
self.assertFalse(under_dev_project in listed_projects) | ||
self.assertFalse(test_project in listed_projects) | ||
self.assertTrue(project in listed_projects) | ||
|
||
|
||
class ProjectViewTests(TestCase): | ||
|
||
test_username = 'testuser' | ||
test_email = '[email protected]' | ||
test_password = 'testpass' | ||
|
||
def setUp(self): | ||
self.client = Client() | ||
self.locale = 'en' | ||
django_user = User( | ||
username=self.test_username, | ||
email=self.test_email, | ||
) | ||
self.user = create_profile(django_user) | ||
self.user.set_password(self.test_password) | ||
self.user.save() | ||
|
||
def test_all_kinds_of_projects_appear_in_listing(self): | ||
|
||
#Should appear in listing | ||
challenge = Project(under_development=False, test=False, | ||
category=Project.CHALLENGE) | ||
challenge.save() | ||
|
||
course = Project(under_development=False, test=False, | ||
category=Project.COURSE) | ||
course.save() | ||
from signups.models import Signup | ||
sign_up = Signup(project=course, author=self.user, | ||
status=Signup.MODERATED) | ||
sign_up.save() | ||
|
||
study_group = Project(under_development=False, test=False, | ||
category=Project.STUDY_GROUP) | ||
study_group.save() | ||
sign_up = Signup(project=study_group, author=self.user, | ||
status=Signup.NON_MODERATED) | ||
sign_up.save() | ||
|
||
#Should not appear in listing | ||
test_challenge = Project(under_development=False, test=True, | ||
category=Project.CHALLENGE) | ||
test_challenge.save() | ||
|
||
closed_study_group = Project(under_development=False, test=False, | ||
category=Project.STUDY_GROUP) | ||
closed_study_group.save() | ||
sign_up = Signup(project=closed_study_group, author=self.user, | ||
status=Signup.CLOSED) | ||
sign_up.save() | ||
|
||
response = self.client.get('/%s/groups/?all_languages=on' % | ||
(self.locale)) | ||
print response.context['pagination_current_page'].object_list | ||
self.assertEqual(3, | ||
len(response.context['pagination_current_page'].object_list)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,8 +46,7 @@ | |
|
||
|
||
def learn(request, max_count=24): | ||
projects = Project.objects.filter(not_listed=False, | ||
deleted=False).order_by('-created_on') | ||
projects = Project.get_listed_projects() | ||
get_params = request.GET.copy() | ||
if not 'language' in get_params: | ||
get_params['language'] = get_language() | ||
|
@@ -60,19 +59,9 @@ def learn(request, max_count=24): | |
'infinite_scroll': request.GET.get('infinite_scroll', False), | ||
} | ||
if form.is_valid(): | ||
archived = form.cleaned_data['archived'] | ||
under_development = form.cleaned_data['under_development'] | ||
projects = projects.filter(archived=archived, | ||
under_development=under_development) | ||
closed_signup = form.cleaned_data['closed_signup'] | ||
if closed_signup: | ||
projects = projects.exclude( | ||
category=Project.CHALLENGE).filter( | ||
sign_up__status=Signup.CLOSED) | ||
else: | ||
projects = projects.filter(Q(category=Project.CHALLENGE) | ||
| Q(sign_up__status=Signup.MODERATED) | ||
| Q(sign_up__status=Signup.NON_MODERATED)) | ||
projects = projects.filter(Q(category=Project.CHALLENGE) | ||
| Q(sign_up__status=Signup.MODERATED) | ||
| Q(sign_up__status=Signup.NON_MODERATED)) | ||
featured = form.cleaned_data['featured'] | ||
if featured == project_forms.ProjectsFilterForm.SHOWCASE: | ||
context['learn_showcase'] = True | ||
|
@@ -847,6 +836,7 @@ def admin_metrics_data_ajax(request, slug): | |
participants = project.participants( | ||
include_deleted=True).order_by('user__username') | ||
participant_profiles = (participant.user for participant in participants) | ||
tracker_models.update_metrics_cache(project) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this came with the pull, but cannot see it in the latest file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this line was removed in a previous commit, don't know how the pull managed to put them back? |
||
metrics = tracker_models.metrics_summary(project, participant_profiles) | ||
json = simplejson.dumps( | ||
{'aaData': list(metrics)}, | ||
|
@@ -861,6 +851,7 @@ def export_detailed_csv(request, slug): | |
"""Display detailed CSV for certain users.""" | ||
project = get_object_or_404(Project, slug=slug) | ||
# Preprocessing | ||
tracker_models.update_metrics_cache(project) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this came with the pull, but cannot see it in the latest file. |
||
organizers = project.organizers(include_deleted=True).order_by('user__username') | ||
organizer_profiles = (organizer.user for organizer in organizers) | ||
organizer_ids = organizers.values('user_id') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woops! what was I thinking? :)
will have some time over the weekend to amend this. thanks for the review!