mirror of
https://github.com/evennia/evennia.git
synced 2026-03-26 09:46:32 +01:00
sethelp db help entry creation fix, @laxy_property removed
evennia.web.website.tests all pass evennia.commands.default.tests.TestHelp all pass (sethelp command test is in that unit test)
This commit is contained in:
parent
b65a3ab1db
commit
d2f410ee26
3 changed files with 17 additions and 16 deletions
|
|
@ -57,10 +57,6 @@ class HelpEntry(SharedMemoryModel):
|
|||
"help key", max_length=255, unique=True, help_text="key to search for"
|
||||
)
|
||||
|
||||
@lazy_property
|
||||
def key(self):
|
||||
return self.db_key
|
||||
|
||||
# help category
|
||||
db_help_category = models.CharField(
|
||||
"help category",
|
||||
|
|
@ -69,10 +65,6 @@ class HelpEntry(SharedMemoryModel):
|
|||
help_text="organizes help entries in lists",
|
||||
)
|
||||
|
||||
@lazy_property
|
||||
def help_category(self):
|
||||
return self.db_help_category
|
||||
|
||||
# the actual help entry text, in any formatting.
|
||||
db_entrytext = models.TextField(
|
||||
"help entry", blank=True, help_text="the main body of help text"
|
||||
|
|
@ -233,11 +225,10 @@ class HelpEntry(SharedMemoryModel):
|
|||
"""
|
||||
|
||||
try:
|
||||
url = reverse(
|
||||
return reverse(
|
||||
"%s-detail" % slugify(self._meta.verbose_name),
|
||||
kwargs={"category": slugify(self.db_help_category), "topic": slugify(self.db_key)},
|
||||
)
|
||||
return url
|
||||
except Exception:
|
||||
return "#"
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@
|
|||
<hr />
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{% url 'help' %}">Help Index</a></li>
|
||||
<li class="breadcrumb-item"><a href="{% url 'help' %}#{{ object.help_category }}">{{ object.help_category|title }}</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">{{ object.key|title }}</li>
|
||||
<li class="breadcrumb-item"><a href="{% url 'help' %}#{{ object.web_help_category }}">{{ object.help_category|title }}</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">{{ object.web_help_key|title }}</li>
|
||||
</ol>
|
||||
<hr />
|
||||
|
||||
|
|
@ -62,7 +62,7 @@
|
|||
{% endif %}
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">{{ object.help_category|title }}</div>
|
||||
<div class="card-header">{{ object.web_help_category|title }}</div>
|
||||
|
||||
<ul class="list-group list-group-flush">
|
||||
{% for topic in topic_list %}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,10 @@ def get_help_category(help_entry, slugify_cat=True):
|
|||
Returns:
|
||||
help_category (str): The category for the help entry.
|
||||
"""
|
||||
help_category = getattr(help_entry, 'help_category', DEFAULT_HELP_CATEGORY)
|
||||
help_category = getattr(help_entry, 'help_category', None)
|
||||
if not help_category:
|
||||
help_category = getattr(help_entry, 'db_help_category', DEFAULT_HELP_CATEGORY)
|
||||
# if one does not exist, create a category for ease of use with web views html templates
|
||||
if not hasattr(help_entry, 'web_help_category'):
|
||||
setattr(help_entry, 'web_help_category', slugify(help_category))
|
||||
return slugify(help_category) if slugify_cat else help_category
|
||||
|
|
@ -46,9 +49,16 @@ def get_help_topic(help_entry):
|
|||
help_entry (HelpEntry, FileHelpEntry or Command): Help entry instance.
|
||||
|
||||
Returns:
|
||||
topic (str): The topic of the help entry. Default is 'unknown_topic'.
|
||||
help_topic (str): The topic of the help entry. Default is 'unknown_topic'.
|
||||
"""
|
||||
return getattr(help_entry, 'key', 'unknown_topic')
|
||||
help_topic = getattr(help_entry, 'key', None)
|
||||
# if object has no key, assume it is a db help entry.
|
||||
if not help_topic:
|
||||
help_topic = getattr(help_entry, 'db_key', 'unknown_topic')
|
||||
# if one does not exist, create a key for ease of use with web views html templates
|
||||
if not hasattr(help_entry, 'web_help_key'):
|
||||
setattr(help_entry, 'web_help_key', slugify(help_topic))
|
||||
return help_topic
|
||||
|
||||
|
||||
def can_read_topic(cmd_or_topic, account):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue