Skip to content
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

Bookmarking added and dashboard update #210

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ jobs:
- uses: actions/checkout@v2
- uses: ammaraskar/sphinx-action@master
with:
pre-build-command: "pip install 'sphinx==7.1.2' --force-reinstall"
docs-folder: "docs/"
14 changes: 7 additions & 7 deletions turkle/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ def has_delete_permission(self, request, obj=None):


class TaskAssignmentAdmin(admin.ModelAdmin):
"""View for assignments to expire abandoned ones"""
"""View for assignments to expire open ones"""

class Media:
css = {
Expand All @@ -1225,17 +1225,17 @@ def changelist_view(self, request, extra_context=None):
return super().changelist_view(request, extra_context)

@staticmethod
def expire_abandoned_assignments(request):
(total_deleted, _) = TaskAssignment.expire_all_abandoned()
messages.info(request, 'All {} abandoned Tasks have been expired'.format(total_deleted))
def expire_open_assignments(request):
(total_deleted, _) = TaskAssignment.expire_all_open()
messages.info(request, 'All {} open Tasks have been expired'.format(total_deleted))
return redirect(reverse('admin:turkle_taskassignment_changelist'))

def get_urls(self):
urls = super().get_urls()
my_urls = [
path('expire_abandoned_assignments/',
self.admin_site.admin_view(self.expire_abandoned_assignments),
name='turkle_expire_abandoned_assignments'),
path('expire_open_assignments/',
self.admin_site.admin_view(self.expire_open_assignments),
name='turkle_expire_open_assignments'),
]
return my_urls + urls

Expand Down
4 changes: 2 additions & 2 deletions turkle/management/commands/expire_assignments.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class Command(BaseCommand):

def handle(self, *args, **options):
t0 = datetime.now()
(total_deleted, _) = TaskAssignment.expire_all_abandoned()
(total_deleted, _) = TaskAssignment.expire_all_open()
t = datetime.now()
dt = (t - t0).total_seconds()
logging.basicConfig(format="%(asctime)-15s %(message)s", level=logging.INFO)
logging.info('TURKLE: Expired {0} abandoned Task Assignments in {1:.3f} seconds'.
logging.info('TURKLE: Expired {0} open Task Assignments in {1:.3f} seconds'.
format(total_deleted, dt))
45 changes: 45 additions & 0 deletions turkle/migrations/0014_bookmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Generated by Django 4.2.6 on 2024-03-21 14:02

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("turkle", "0013_activeproject_activeuser"),
]

operations = [
migrations.CreateModel(
name="Bookmark",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("bookmarked", models.BooleanField(default=False)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"batch",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="turkle.batch"
),
),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
],
),
]
9 changes: 8 additions & 1 deletion turkle/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class Meta:
updated_at = models.DateTimeField(auto_now=True, db_index=True)

@classmethod
def expire_all_abandoned(cls):
def expire_all_open(cls):
result = cls.objects.\
filter(completed=False).\
filter(expires_at__lt=timezone.now()).\
Expand Down Expand Up @@ -938,3 +938,10 @@ def completed_assignments(self):
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)
updated_at = models.DateTimeField(auto_now=True)

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion turkle/static/turkle/bootstrap-4.1.3/css/bootstrap.css.map

This file was deleted.

7 changes: 0 additions & 7 deletions turkle/static/turkle/bootstrap-4.1.3/css/bootstrap.min.css

This file was deleted.

This file was deleted.

Loading
Loading