Repository: WeblateOrg/weblate

Issue:
Glossary source string "Explanation" field is read-only
### Describe the issue

The source string is generally set to read-only which I kind of understand since the string itself should probably not be modified as it is likely used as a key in the database.

But I wonder why this extends to the "Explanation" field.

![image](https://github.com/WeblateOrg/weblate/assets/16470072/ef6d2513-a12a-495f-a236-0880e33acc70)

The problem with this is that often, users who misunderstand the difference between the "Explanation", "Translation Explanation" and "Comment" fields create a new glossary entry and fill the Explanation field with something invalid, like a comment or an explanation in their native language instead of English.

It seems there is no way to edit the explanation afterwards making it impossible to correct any mistakes made when adding the phrase.

I got this via hosted Weblate, and since I am just a user, it's possible that I am missing privileges, but since I read similar issues with read-only source language fields, I thought maybe it is a real issue.

### I already tried

- [X] I've read and searched [the documentation](https://docs.weblate.org/).
- [X] I've searched for similar issues in this repository.

### Steps to reproduce the behavior

1. Create a new glossary term
2. Enter text into the "Explanation" field
3. In the Glossary entry, click "English" to get to the source string
4. The "Explanation" field cannot be edited.

### Expected behavior

Since any user can add a glossary term with an Explanation text, I would likewise expect any user to be able to modify that Explanation text.



Discussion:
Editing is currently limited only to users who have "Edit glossary entry", what is the default permission. Can you please share link to the glossary entry, so that we can take a look?
@nijel Thanks for your quick reply:

The German entry (I can edit the translation explanation)
https://hosted.weblate.org/translate/godot-engine/glossary/de/?checksum=17aa82dc6463c522

The Source entry (read-only)
https://hosted.weblate.org/translate/godot-engine/glossary/en/?checksum=17aa82dc6463c522

I seem to have the "edit glossary entry" rights, but only for my own language, the source language is read-only. That is, I can type in the "Explanation" field, but I cannot save.
This issue has been automatically marked as stale because there wasn’t any recent activity.

It will be closed soon if no further action occurs.

Thank you for your contributions!
Hmm, I can edit it there, so it seems that there is something wrong with the permission check.

Resolving patch:
diff --git a/weblate/auth/permissions.py b/weblate/auth/permissions.py
--- a/weblate/auth/permissions.py
+++ b/weblate/auth/permissions.py
@@ -477,10 +477,10 @@ def check_announcement_delete(user, permission, obj):
 def check_unit_flag(user, permission, obj):
     if isinstance(obj, Unit):
         obj = obj.translation
-    if not obj.component.is_glossary or obj.is_source:
+    if not obj.component.is_glossary:
         return user.has_perm("source.edit", obj)
 
-    return user.has_perm("glossary.edit", obj)
+    return check_can_edit(user, "glossary.edit", obj)
 
 
 @register_perm("memory.edit", "memory.delete")
diff --git a/weblate/trans/models/translation.py b/weblate/trans/models/translation.py
--- a/weblate/trans/models/translation.py
+++ b/weblate/trans/models/translation.py
@@ -185,7 +185,7 @@ def is_template(self):
 
         This means that translations should be propagated as sources to others.
         """
-        return self.filename == self.component.template
+        return self.component.template and self.filename == self.component.template
 
     @cached_property
     def is_source(self):


Test patch: