Skip to content

Commit

Permalink
chore: enable flake8-django (DJ) rule in ruff config
Browse files Browse the repository at this point in the history
  • Loading branch information
afuetterer committed Oct 17, 2023
1 parent 12a55af commit 1160ee4
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 20 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ line-length = 120
select = [
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"DJ", # flake8-django
"E", # pycodestyle
"F", # pyflakes
"I", # isort
Expand Down
13 changes: 12 additions & 1 deletion rdmo/conditions/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@ class ConditionAdminForm(forms.ModelForm):

class Meta:
model = Condition
fields = '__all__'
fields = [
"uri",
"uri_prefix",
"uri_path",
"comment",
"locked",
"editors",
"source",
"relation",
"target_text",
"target_option",
]

def clean(self):
ConditionUniqueURIValidator(self.instance)(self.cleaned_data)
Expand Down
11 changes: 10 additions & 1 deletion rdmo/domain/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ class AttributeAdminForm(forms.ModelForm):

class Meta:
model = Attribute
fields = '__all__'
fields = [
'uri',
'uri_prefix',
'key',
'path',
'comment',
'locked',
'editors',
'parent',
]

def clean(self):
AttributeUniqueURIValidator(self.instance)(self.cleaned_data)
Expand Down
10 changes: 5 additions & 5 deletions rdmo/projects/models/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

class Integration(models.Model):

objects = IntegrationManager()

project = models.ForeignKey(
'Project', on_delete=models.CASCADE, related_name='integrations',
verbose_name=_('Project'),
Expand All @@ -21,6 +19,8 @@ class Integration(models.Model):
help_text=_('The key of the provider for this integration.')
)

objects = IntegrationManager()

class Meta:
ordering = ('project__title', )
verbose_name = _('Integration')
Expand All @@ -29,13 +29,13 @@ class Meta:
def __str__(self):
return f'{self.project.title} / {self.provider_key}'

def get_absolute_url(self):
return reverse('project', kwargs={'pk': self.project.pk})

@property
def provider(self):
return get_plugin('PROJECT_ISSUE_PROVIDERS', self.provider_key)

def get_absolute_url(self):
return reverse('project', kwargs={'pk': self.project.pk})

def save_options(self, options):
for field in self.provider.fields:
try:
Expand Down
4 changes: 2 additions & 2 deletions rdmo/projects/models/invite.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ class Invite(models.Model):

key_salt = 'rdmo.projects.models.invite.Invite'

objects = InviteManager()

project = models.ForeignKey(
'Project', on_delete=models.CASCADE, related_name='invites',
verbose_name=_('Project'),
Expand Down Expand Up @@ -45,6 +43,8 @@ class Invite(models.Model):
help_text=_('The timestamp for this invite.')
)

objects = InviteManager()

class Meta:
ordering = ('timestamp', )
verbose_name = _('Invite')
Expand Down
3 changes: 1 addition & 2 deletions rdmo/projects/models/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

class Issue(models.Model):

objects = IssueManager()

ISSUE_STATUS_OPEN = 'open'
ISSUE_STATUS_IN_PROGRESS = 'in_progress'
ISSUE_STATUS_CLOSED = 'closed'
Expand All @@ -39,6 +37,7 @@ class Issue(models.Model):
help_text=_('The status for this issue.')
)

objects = IssueManager()
class Meta:
ordering = ('project__title', )
verbose_name = _('Issue')
Expand Down
4 changes: 2 additions & 2 deletions rdmo/projects/models/membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

class Membership(models.Model):

objects = MembershipManager()

ROLE_CHOICES = (
('owner', _('Owner')),
('manager', _('Manager')),
Expand All @@ -33,6 +31,8 @@ class Membership(models.Model):
help_text=_('The role for this membership.')
)

objects = MembershipManager()

class Meta:
ordering = ('project__title', )
verbose_name = _('Membership')
Expand Down
2 changes: 1 addition & 1 deletion rdmo/questions/models/question.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class Question(Model, TranslationMixin):
help_text=_('The default text value for this question in the quaternary language.')
)
default_text_lang5 = models.TextField(
null=True, blank=True,
default="", blank=True,
verbose_name=_('Default text value (quinary)'),
help_text=_('The default text value for this question in the quinary language.')
)
Expand Down
28 changes: 27 additions & 1 deletion rdmo/tasks/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,33 @@ class TaskAdminForm(forms.ModelForm):

class Meta:
model = Task
fields = '__all__'
fields = [
"uri",
"uri_prefix",
"uri_path",
"comment",
"locked",
"catalogs",
"sites",
"editors",
"groups",
"title_lang1",
"title_lang2",
"title_lang3",
"title_lang4",
"title_lang5",
"text_lang1",
"text_lang2",
"text_lang3",
"text_lang4",
"text_lang5",
"start_attribute",
"end_attribute",
"days_before",
"days_after",
"conditions",
"available",
]

def clean(self):
TaskUniqueURIValidator(self.instance)(self.cleaned_data)
Expand Down
4 changes: 2 additions & 2 deletions rdmo/tasks/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

class Task(TranslationMixin, models.Model):

objects = TaskManager()

uri = models.URLField(
max_length=800, blank=True,
verbose_name=_('URI'),
Expand Down Expand Up @@ -145,6 +143,8 @@ class Task(TranslationMixin, models.Model):
help_text=_('Designates whether this task is generally available for projects.')
)

objects = TaskManager()

class Meta:
ordering = ('uri',)
verbose_name = _('Task')
Expand Down
24 changes: 23 additions & 1 deletion rdmo/views/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,29 @@ class ViewAdminForm(forms.ModelForm):

class Meta:
model = View
fields = '__all__'
fields = [
"uri",
"uri_prefix",
"uri_path",
"comment",
"locked",
"catalogs",
"sites",
"editors",
"groups",
"template",
"title_lang1",
"title_lang2",
"title_lang3",
"title_lang4",
"title_lang5",
"help_lang1",
"help_lang2",
"help_lang3",
"help_lang4",
"help_lang5",
"available",
]

def clean(self):
ViewUniqueURIValidator(self.instance)(self.cleaned_data)
Expand Down
4 changes: 2 additions & 2 deletions rdmo/views/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

class View(models.Model, TranslationMixin):

objects = ViewManager()

uri = models.URLField(
max_length=800, blank=True,
verbose_name=_('URI'),
Expand Down Expand Up @@ -125,6 +123,8 @@ class View(models.Model, TranslationMixin):
help_text=_('Designates whether this view is generally available for projects.')
)

objects = ViewManager()

class Meta:
ordering = ('uri', )
verbose_name = _('View')
Expand Down

0 comments on commit 1160ee4

Please sign in to comment.