https://github.com/GrandComicsDatabase/gcd-django/pull/741
(24 files)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
@gemini-code-assist[bot] commented on this pull request.
This pull request introduces support for multiple feature names by adding the FeatureNameDetail model and its revision counterpart, updating references across stories, logos, views, and forms. The review feedback identifies several critical issues, including the use of deprecated urlresolvers which will fail in Django 5.x, a potential AttributeError in FeatureNameDetailRevision due to a missing sort_name attribute, a missing import of Formset in the feature forms, and an optimization opportunity to avoid a redundant database query in feature_logo_feature_issues.
In apps/gcd/models/feature.py:
> + def get_absolute_url(self):
+ return urlresolvers.reverse(
+ 'show_feature',
+ kwargs={'feature_id': self.feature.id})
In Django 2.0+, django.core.urlresolvers was removed in favor of django.urls. Using urlresolvers.reverse will raise a NameError or ImportError in Django 5.x. Please import and use reverse from django.urls instead.
- def get_absolute_url(self):
- return urlresolvers.reverse(
- 'show_feature',
- kwargs={'feature_id': self.feature.id})
+ def get_absolute_url(self):
+ from django.urls import reverse
+ return reverse(
+ 'show_feature',
+ kwargs={'feature_id': self.feature.id})
In apps/gcd/models/feature.py:
> + def render_issue_count(self, record):
+ url = urlresolvers.reverse(
+ 'feature_logo_feature_issues',
+ kwargs={'feature_id': self.feature_id,
+ 'feature_logo_id': record.id})
+ return mark_safe('<a href="%s">%s</a>' % (url,
+ record.issue_count))
Similar to get_absolute_url, urlresolvers.reverse should be replaced with django.urls.reverse to ensure compatibility with Django 5.x.
- def render_issue_count(self, record):
- url = urlresolvers.reverse(
- 'feature_logo_feature_issues',
- kwargs={'feature_id': self.feature_id,
- 'feature_logo_id': record.id})
- return mark_safe('<a href="%s">%s</a>' % (url,
- record.issue_count))
+ def render_issue_count(self, record):
+ from django.urls import reverse
+ url = reverse(
+ 'feature_logo_feature_issues',
+ kwargs={'feature_id': self.feature_id,
+ 'feature_logo_id': record.id})
+ return mark_safe('<a href="%s">%s</a>' % (url,
+ record.issue_count))
> + def _imps_for(self, field_name): + if field_name == 'sort_name': + if self.sort_name == self.name: + return 0 + else: + return 1
FeatureNameDetailRevision does not have a sort_name attribute, so accessing self.sort_name will raise an AttributeError. Instead, you can compute the sort name based on self.name and self.leading_article using remove_leading_article if leading_article is True.
- def _imps_for(self, field_name): - if field_name == 'sort_name': - if self.sort_name == self.name: - return 0 - else: - return 1 + def _imps_for(self, field_name): + if field_name == 'sort_name': + sort_name = remove_leading_article(self.name) if self.leading_article else self.name + if sort_name == self.name: + return 0 + else: + return 1
> +from .support import (KeywordBaseForm, FEATURE_HELP_LINKS, HiddenInputWithHelp,
_get_comments_form_field, combine_reverse_relations,
GENERIC_ERROR_MESSAGE, _create_embedded_image_revision,
_save_runtime_embedded_image_revision)
Formset is used in the layout of FeatureRevisionForm but is not imported in this file, which will cause a NameError at runtime. Please import Formset from .support.
-from .support import (KeywordBaseForm, FEATURE_HELP_LINKS, HiddenInputWithHelp, - _get_comments_form_field, combine_reverse_relations, - GENERIC_ERROR_MESSAGE, _create_embedded_image_revision, - _save_runtime_embedded_image_revision) +from .support import (KeywordBaseForm, FEATURE_HELP_LINKS, HiddenInputWithHelp, + _get_comments_form_field, combine_reverse_relations, + GENERIC_ERROR_MESSAGE, _create_embedded_image_revision, + _save_runtime_embedded_image_revision, Formset)
> 'heading': 'for feature logo %s' % (feature_logo)
}
template = 'gcd/search/tw_list_sortable.html'
- table = IssueTable(issues,
- attrs={'class': 'sortable_listing'},
- template_name=TW_SORT_TABLE_TEMPLATE,
- order_by=('publication_date'))
+ table = _table_issues_list_or_grid(request, issues, context)
+ return generic_sortable_list(request, issues, table, template, context)
+
+
+def feature_logo_feature_issues(request, feature_logo_id, feature_id):
+ feature_logo = get_gcd_object(FeatureLogo, feature_logo_id)
+ feature = get_gcd_object(Feature, feature_id)
+
+ if feature_logo.feature.all()[0].feature_type.id == 1:
Since the feature object is already retrieved and passed into this function, you can directly access feature.feature_type.id instead of performing an unnecessary database query and list indexing with feature_logo.feature.all()[0].feature_type.id. This is both more efficient and safer (avoids potential IndexError).
- if feature_logo.feature.all()[0].feature_type.id == 1: + if feature.feature_type.id == 1:
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
@jochengcd pushed 1 commit.
—
View it on GitHub or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
@jochengcd commented on this pull request.
In apps/gcd/models/feature.py:
> + def get_absolute_url(self):
+ return urlresolvers.reverse(
+ 'show_feature',
+ kwargs={'feature_id': self.feature.id})
import django.urls as urlresolvers
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()