Code

Opened 5 years ago

Closed 5 years ago

Last modified 3 years ago

#11100 closed (fixed)

Template designers have no easy way to specify anchor pattern for Comment.get_absolute_url

Reported by: idangazit Owned by: nobody
Component: contrib.comments Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Comment.get_absolute_url() takes an anchor_pattern argument which specifies the desired form of the named anchor for a comment.

    def get_absolute_url(self, anchor_pattern="#c%(id)s"):
        return self.get_content_object_url() + (anchor_pattern % self.__dict__)

Because there's no way to specify the desired anchor pattern when calling from a template, designers are stuck with the default anchor pattern unless a developer steps in to help.

The comments app is full of template tags which make life easy for the designer, seems like what's needed here is a get_comment_permalink template tag which takes an anchor pattern as an optional argument.

Attachments (1)

r10753_get_comment_permalink.diff (4.0 KB) - added by idangazit 5 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 5 years ago by idangazit

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Patch adds a new simple_tag, get_comment_permalink. Jezdez wrote originally as a filter, I adapted to simple_tag and documented.

It's worth noting that this patch builds on the one in #9967. If I borked the patch submission guidelines, apologies and let me know so I can do it right next time.

comment:2 Changed 5 years ago by jezdez

  • milestone set to 1.2
  • Needs tests set
  • Triage Stage changed from Unreviewed to Accepted

Changed 5 years ago by idangazit

comment:3 Changed 5 years ago by idangazit

  • Needs tests unset

comment:4 Changed 5 years ago by jezdez

  • Resolution set to fixed
  • Status changed from new to closed

(In [12080]) Fixed #11100 - Added get_comment_permalink template tag to comments app to be able to customize the anchor pattern of a comment from the template. Thanks to Idan Gazit for the patch.

comment:5 Changed 3 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.