Skip to content

Commit

Permalink
Ruff compliance for DandisetStar model and admin integration
Browse files Browse the repository at this point in the history
  • Loading branch information
bendichter committed Dec 26, 2024
1 parent 645c326 commit db92523
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dandiapi/api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
AssetBlob,
AuditRecord,
Dandiset,
DandisetStar,
Upload,
UserMetadata,
Version,
DandisetStar,
)
from dandiapi.api.views.users import social_account_to_dict
from dandiapi.zarr.tasks import ingest_dandiset_zarrs
Expand Down
30 changes: 26 additions & 4 deletions dandiapi/api/migrations/0014_dandisetstar.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Generated by Django 4.2.17 on 2024-12-26 14:24
from __future__ import annotations

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),
('api', '0013_remove_assetpath_consistent_slash_and_more'),
Expand All @@ -16,10 +16,32 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='DandisetStar',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
(
'id',
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name='ID',
),
),
('created', models.DateTimeField(auto_now_add=True)),
('dandiset', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='stars', to='api.dandiset')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='starred_dandisets', to=settings.AUTH_USER_MODEL)),
(
'dandiset',
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name='stars',
to='api.dandiset',
),
),
(
'user',
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name='starred_dandisets',
to=settings.AUTH_USER_MODEL,
),
),
],
options={
'unique_together': {('user', 'dandiset')},
Expand Down
6 changes: 4 additions & 2 deletions dandiapi/api/models/dandiset.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from __future__ import annotations

from django.contrib.auth.models import User
from django.db import models
from django_extensions.db.models import TimeStampedModel
from guardian.models import GroupObjectPermissionBase, UserObjectPermissionBase
from guardian.shortcuts import assign_perm, get_objects_for_user, get_users_with_perms, remove_perm
from django.contrib.auth.models import User
from django.db.models import Count


class DandisetManager(models.Manager):
Expand Down Expand Up @@ -147,3 +146,6 @@ class DandisetStar(models.Model):

class Meta:
unique_together = ('user', 'dandiset')

def __str__(self) -> str:
return f'Star {self.user.username}{self.dandiset.identifier}'

0 comments on commit db92523

Please sign in to comment.