Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
roseva1 committed Nov 13, 2023
1 parent 77e1e12 commit ca9c9d1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions turkle/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from django.urls import path, reverse
from django.utils import timezone
from django.utils.html import format_html, format_html_join
from django.utils.translation import ngettext
from guardian.admin import GuardedModelAdmin
from guardian.shortcuts import (assign_perm, get_groups_with_perms, get_users_with_perms,
remove_perm)
Expand Down
3 changes: 2 additions & 1 deletion turkle/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,8 @@ def most_recent(self):
return self.last_finished_time
most_recent.admin_order_field = 'last_finished_time'


class Bookmark(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
batch = models.ForeignKey(Batch, on_delete=models.CASCADE)
bookmarked = models.BooleanField(default=False)
bookmarked = models.BooleanField(default=False)
9 changes: 5 additions & 4 deletions turkle/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
from django.utils.dateparse import parse_date
from django.utils.datastructures import MultiValueDictKeyError

from .models import Task, TaskAssignment, Batch, Project, Bookmark, User
from .models import Task, TaskAssignment, Batch, Project, Bookmark

User = get_user_model()

logger = logging.getLogger(__name__)


def handle_db_lock(func):
"""Decorator that catches database lock errors from sqlite"""
@wraps(func)
Expand Down Expand Up @@ -76,8 +77,8 @@ def process_bookmark(query_dict):
bookmark_status = query_dict.get('bookmarked') == 'true'
batch = Batch.objects.get(name=batch_name)
bookmark, created = Bookmark.objects.get_or_create(
user=get_user(request),
batch=batch,
user=get_user(request),
batch=batch,
defaults={'bookmarked': bookmark_status}
)
if not created:
Expand All @@ -95,7 +96,7 @@ def get_bookmark_status(batch):
"""Access batch bookmark status for a user
"""
bookmark = Bookmark.objects.filter(
user=get_user(request),
user=get_user(request),
batch__name=batch['name']
).values_list('bookmarked', flat=True).first()
return 'checked' if bookmark else ''
Expand Down

0 comments on commit ca9c9d1

Please sign in to comment.