<commit_before>import logging
import os
import shutil
import zipfile
from datetime import datetime

from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.contrib import messages
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, HttpResponseNotAllowed, Http404
from django.shortcuts import get_object_or_404, render_to_response
from django.template import RequestContext
from django.views.generic import ListView
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext_lazy as _

from guardian.shortcuts import assign

from builds.forms import AliasForm, VersionForm
from builds.filters import VersionFilter
from builds.models import VersionAlias, Version
from oauth.models import GithubProject
from oauth import utils as oauth_utils
from projects.forms import (ImportProjectForm, build_versions_form,
                            build_upload_html_form, SubprojectForm,
                            UserForm, EmailHookForm, TranslationForm,
                            AdvancedProjectForm, RedirectForm, WebHookForm)
from projects.models import Project, EmailHook, WebHook
from projects import constants
from redirects.models import Redirect

from bookmarks.models import Bookmark

log = logging.getLogger(__name__)

class ProjectDashboard(ListView):

    """
    A dashboard!  If you aint know what that means you aint need to.
    Essentially we show you an overview of your content.
    """
    model = Project
    template_name = 'projects/project_dashboard.html'

    @method_decorator(login_required)
    def dispatch(self, *args, **kwargs):
        return super(ProjectDashboard, self).dispatch(*args, **kwargs)

    def get_queryset(self):
        return self.request.user.projects.live()

    def get_context_data(self, **kwargs):
        context = super(ProjectDashboard, self).get_context_data(**kwargs)
        qs = (Version.objects.active(user=self.request.user)
              .filter(project__users__in=[self.request.user]))
        filter = VersionFilter(
            constants.IMPORTANT_VERSION_FILTERS, queryset=self.get_queryset())
        context['filter'] = filter

        try:
            bookmarks = Bookmark.objects.filter(user=self.request.user, )
        except (Bookmark.DoesNotExist):
            bookmark = None
        context['bookmark_list'] = bookmarks[:3]

        return context<commit_msg>added exists() check for bookmarks filter query since filter doesn't raise DoesNotExist<commit_after>import logging
import os
import shutil
import zipfile
from datetime import datetime

from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.contrib import messages
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, HttpResponseNotAllowed, Http404
from django.shortcuts import get_object_or_404, render_to_response
from django.template import RequestContext
from django.views.generic import ListView
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext_lazy as _

from guardian.shortcuts import assign

from builds.forms import AliasForm, VersionForm
from builds.filters import VersionFilter
from builds.models import VersionAlias, Version
from oauth.models import GithubProject
from oauth import utils as oauth_utils
from projects.forms import (ImportProjectForm, build_versions_form,
                            build_upload_html_form, SubprojectForm,
                            UserForm, EmailHookForm, TranslationForm,
                            AdvancedProjectForm, RedirectForm, WebHookForm)
from projects.models import Project, EmailHook, WebHook
from projects import constants
from redirects.models import Redirect

from bookmarks.models import Bookmark

log = logging.getLogger(__name__)

class ProjectDashboard(ListView):

    """
    A dashboard!  If you aint know what that means you aint need to.
    Essentially we show you an overview of your content.
    """
    model = Project
    template_name = 'projects/project_dashboard.html'

    @method_decorator(login_required)
    def dispatch(self, *args, **kwargs):
        return super(ProjectDashboard, self).dispatch(*args, **kwargs)

    def get_queryset(self):
        return self.request.user.projects.live()

    def get_context_data(self, **kwargs):
        context = super(ProjectDashboard, self).get_context_data(**kwargs)
        qs = (Version.objects.active(user=self.request.user)
              .filter(project__users__in=[self.request.user]))
        filter = VersionFilter(
            constants.IMPORTANT_VERSION_FILTERS, queryset=self.get_queryset())
        context['filter'] = filter

        bookmarks = Bookmark.objects.filter(user=self.request.user)

        if bookmarks.exists:
            context['bookmark_list'] = bookmarks[:3]
        else:
            bookmarks = None
            
        return context
{'fraction_non_alphanumeric': 0.0673758865248227, 'fraction_numerical': 0.0027580772261623326, 'mean_word_length': 3.7626641651031894, 'pattern_counts': {'":': 0, '<': 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': '7042914', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1298, 'n_words': 386}