Update topic after editing time limit has passed

I would like to let users bump topic with a help of a button “Bump topic” as long as topic is not closed or archived.

I’m almost there but stumbeled upon TopicController’s update method … more specifically upon guardian.ensure_can_edit!(topic) inside the update method. It prevents user from changing their older posts.

Is my only option to go with direct SQL update of a topic or is there “standard” way to achieve this?

1 个赞

Wait, I am unclear, can you explain exactly what you are trying to achieve here?

1 个赞

Because in general I would like indeed topic to be closed for editing… in this case it’s a category where people sell their old/used stuff. In the beginning people should be able to edit their posts as we have certain rules they should follow (photos, necessary information etc). After some time it’s safe to say the post is “finished” apart the price which can go down. People are allowed to “bump” their topic with the help of a button which appears 72 hours after last “bump” (whether bu button or some other person’s post in the topic).

So there it is … what I want to achieve. I have a button. I can bump editable posts but what if something is “in the market” for 2 years? 4 years? :slight_smile:

1 个赞

Still not following,

  • Do you want to give end users the ability to “bump” topics and have them show up first in latest, but only once in 48 hours, without forcing them to post on the topic?

  • Are you trying to lift editing limit temporarily from a topic?

Keep in mind once there is more than one post in a topic, editing OP does not bump topic.

1 个赞

Yes, this is exactly what I’m trying to do.

1 个赞

Then I would recommend you would make a plugin with a special controller that simply updates bumped_at on the topic to Time.zone.now and handles all permissions etc in said controller.

3 个赞

有人要求过添加“Bump topic”按钮吗?我有一个客户将 Discourse 用作公司内部问答平台,他希望允许他的同事置顶那些未获得足够关注的主题,而无需添加一个字的“bump”回复。

显然,这可能会让大多数社区感到厌烦,但也许可以将其添加为可选插件或主题组件?:thinking:

我早就创建了这个插件 :slight_smile:

不知道它是否还能用,但你可以试试

(我不再使用它了……所以我不确定)

3 个赞

谢谢!在您的社区中添加该按钮效果如何?我认为对于大多数网站来说,这会很烦人,但可以理解其对问答网站的好处,因为人们正在等待答案,但又不想用无意义的“我也是”帖子来充斥话题。

这现在可以作为主题组件实现。

这实际上是为了配合我的买入/卖出/交换插件而创建的……该插件在主题中添加了上述按钮,并且为了避免用户用“顶帖”(顺便说一句,这是不允许的……我们有规则和版主)“垃圾信息”交易类别。所以当你想要出售某件东西时,你创建了你的主题,并且每 3 天你可以通过点击一个按钮来“顶帖”。

1 个赞