<commit_before>from django import db
from mail import send_html_mail
from mitxmako.shortcuts import render_to_response
from xmodule.modulestore.django import modulestore
from courseware.courses import (get_courses, get_course_with_access, get_course_by_id,
                                get_courses_by_university, sort_by_announcement, sort_by_custom)
from courseware.access import has_access
from student.models import UserTestGroup, CourseEnrollment, UserProfile, Registration, District, State, School
from django.core.urlresolvers import reverse
from django.conf import settings
import json
from student.models import User, UserProfile
from django.http import HttpResponse, HttpResponseForbidden
from pepper_utilities.utils import random_mark
from xmodule.course_module import CourseDescriptor


def course_list(request):
    email = request.GET.get("email", "")
    try:
        UserProfile.objects.get(user__email=email, subscription_status='Imported')
    except:
        email = ""
    filterDic = {'_id.category': 'course', 'metadata.paypal_purchase_link': {"$nin": ("", None)}}  # {"$nin": ("", None)}
    items = modulestore().collection.find(filterDic)
    courses = modulestore()._load_items(list(items), 0)
    return render_to_response("shopping/course_list.html", {'courses': courses, 'email': email})


def registered_for_course(course, user):
    """
    Return True if user is registered for course, else False
    """
    if user is None:
        return False
    if user.is_authenticated():
        return CourseEnrollment.is_enrolled(user, course.id)
    else:
        return False


def course_info(request, course_id):
    course = get_course_with_access(request.user, course_id, 'see_exists')
    registered = registered_for_course(course, request.user)

    if has_access(request.user, course, 'load'):
        course_target = reverse('info', args=[course.id])
    else:
        course_target = reverse('about_course', args=[course.id])

    show_courseware_link = (has_access(request.user, course, 'load') or
                            settings.MITX_FEATURES.get('ENABLE_LMS_MIGRATION'))
<commit_msg>Modify filter of courses list.<commit_after>from django import db
from mail import send_html_mail
from mitxmako.shortcuts import render_to_response
from xmodule.modulestore.django import modulestore
from courseware.courses import (get_courses, get_course_with_access, get_course_by_id,
                                get_courses_by_university, sort_by_announcement, sort_by_custom)
from courseware.access import has_access
from student.models import UserTestGroup, CourseEnrollment, UserProfile, Registration, District, State, School
from django.core.urlresolvers import reverse
from django.conf import settings
import json
from student.models import User, UserProfile
from django.http import HttpResponse, HttpResponseForbidden
from pepper_utilities.utils import random_mark
from xmodule.course_module import CourseDescriptor


def course_list(request):
    email = request.GET.get("email", "")
    try:
        UserProfile.objects.get(user__email=email, subscription_status='Imported')
    except:
        email = ""
    filterDic = {'_id.category': 'course', 'metadata.paypal_purchase_link': {"$ne": None}}  # {"$nin": ("", None)}
    items = modulestore().collection.find(filterDic)
    courses = modulestore()._load_items(list(items), 0)
    return render_to_response("shopping/course_list.html", {'courses': courses, 'email': email})


def registered_for_course(course, user):
    """
    Return True if user is registered for course, else False
    """
    if user is None:
        return False
    if user.is_authenticated():
        return CourseEnrollment.is_enrolled(user, course.id)
    else:
        return False


def course_info(request, course_id):
    course = get_course_with_access(request.user, course_id, 'see_exists')
    registered = registered_for_course(course, request.user)

    if has_access(request.user, course, 'load'):
        course_target = reverse('info', args=[course.id])
    else:
        course_target = reverse('about_course', args=[course.id])

    show_courseware_link = (has_access(request.user, course, 'load') or
                            settings.MITX_FEATURES.get('ENABLE_LMS_MIGRATION'))

{'fraction_non_alphanumeric': 0.0979381443298969, 'fraction_numerical': 0.00046860356138706655, 'mean_word_length': 4.329588014981273, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5033629', 'n_tokens_mistral': 1253, 'n_tokens_neox': 1238, 'n_words': 302}