Browse Source

Prepend group + page slug to wiki edit messages

Since every commit only affects a single file, this will make it much
easier to see what they're affecting (and stop users from needing to
include it manually).
merge-requests/70/head
Deimos 5 years ago
parent
commit
20e22722b0
  1. 6
      tildes/tildes/models/group/group_wiki_page.py
  2. 3
      tildes/tildes/templates/group_wiki_edit_page.jinja2

6
tildes/tildes/models/group/group_wiki_page.py

@ -68,7 +68,7 @@ class GroupWikiPage(DatabaseModel):
# create the directory for the group if it doesn't already exist # create the directory for the group if it doesn't already exist
self.file_path.parent.mkdir(mode=0o755, exist_ok=True) self.file_path.parent.mkdir(mode=0o755, exist_ok=True)
self.edit(markdown, user, f'~{group.path}: Create page "{page_name}"')
self.edit(markdown, user, "Create page")
def __acl__(self) -> Sequence[Tuple[str, Any, str]]: def __acl__(self) -> Sequence[Tuple[str, Any, str]]:
"""Pyramid security ACL.""" """Pyramid security ACL."""
@ -140,6 +140,10 @@ class GroupWikiPage(DatabaseModel):
repo.index.add(str(self.file_path.relative_to(self.BASE_PATH))) repo.index.add(str(self.file_path.relative_to(self.BASE_PATH)))
repo.index.write() repo.index.write()
# Prepend the group name and page slug to the edit message - if you change the
# format of this, make sure to also change the page-editing template to match
edit_message = f"~{self.group.path}/{self.slug}: {edit_message}"
repo.create_commit( repo.create_commit(
repo.head.name, repo.head.name,
author, author,

3
tildes/tildes/templates/group_wiki_edit_page.jinja2

@ -30,8 +30,11 @@
<div class="form-group"> <div class="form-group">
<label class="form-label" for="edit_message">Short edit summary</label> <label class="form-label" for="edit_message">Short edit summary</label>
<div class="input-group">
<span class="input-group-addon">~{{ page.group.path }}/{{ page.slug }}:</span>
<input class="form-input" id="edit_message" name="edit_message" type="text" placeholder="Edit summary" maxlength="80" required> <input class="form-input" id="edit_message" name="edit_message" type="text" placeholder="Edit summary" maxlength="80" required>
</div> </div>
</div>
<div class="form-buttons"> <div class="form-buttons">
<button type="submit" class="btn btn-primary">Save page</button> <button type="submit" class="btn btn-primary">Save page</button>

Loading…
Cancel
Save