DEV: Use category ids in more URLs preferentially

This is a followup to 374534f0
This commit is contained in:
Daniel Waterworth 2019-12-04 09:12:45 +00:00
parent bb69e8942e
commit 6e5fedb312
5 changed files with 5 additions and 4 deletions

View File

@ -107,7 +107,7 @@ export default Controller.extend(ModalFunctionality, {
slug: result.category.slug,
id: result.category.id
});
DiscourseURL.redirectTo("/c/" + Category.slugFor(model));
DiscourseURL.redirectTo(`/c/${Category.slugFor(model)}/${model.id}`);
})
.catch(error => {
this.flash(extractError(error), "error");

View File

@ -79,7 +79,7 @@ function defaultCategoryLinkRenderer(category, opts) {
let restricted = get(category, "read_restricted");
let url = opts.url
? opts.url
: Discourse.getURL("/c/") + Category.slugFor(category);
: Discourse.getURL(`/c/${Category.slugFor(category)}/${category.id}`);
let href = opts.link === false ? "" : url;
let tagName = opts.link === false || opts.link === "false" ? "span" : "a";
let extraClasses = opts.extraClasses ? " " + opts.extraClasses : "";

View File

@ -67,7 +67,7 @@ const Category = RestModel.extend({
@discourseComputed("name")
url() {
return Discourse.getURL("/c/") + Category.slugFor(this);
return Discourse.getURL(`/c/${Category.slugFor(this)}/${this.id}`);
},
@discourseComputed

View File

@ -36,7 +36,7 @@ QUnit.test("Editing the category", async assert => {
assert.ok(!visible(".d-modal"), "it closes the modal");
assert.equal(
DiscourseURL.redirectedTo,
"/c/bug",
"/c/bug/1",
"it does one of the rare full page redirects"
);
});

View File

@ -265,6 +265,7 @@ export default function() {
this.put("/categories/:category_id", request => {
const category = parsePostData(request.requestBody);
category.id = parseInt(request.params.category_id, 10);
if (category.email_in === "duplicate@example.com") {
return response(422, { errors: ["duplicate email"] });