-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix: translation repository browser #19184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b92788a
7e54b1a
d0b8058
b077ac0
8b992c2
2f90a06
d45be02
2ae1b03
ac8d6f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This migration is not based on the current main: Please rename it and adjust dependencies. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Copyright © Michal Čihař <michal@weblate.org> | ||
| # | ||
| # SPDX-License-Identifier: GPL-3.0-or-later | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
| import weblate.utils.render | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("trans", "0073_alter_change_action"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name="component", | ||
| name="repoweb_translations", | ||
| field=models.CharField( | ||
| blank=True, | ||
| help_text="Link to repository browser for translation files, use {{branch}} for branch, {{filename}} and {{line}} as filename and line placeholders. If left empty, the Repository browser above will be used. You might want to strip leading directory by using {{filename|parentdir}}.", | ||
| max_length=200, | ||
| validators=[weblate.utils.render.validate_repoweb], | ||
| verbose_name="Repository browser for translations", | ||
| ), | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -560,6 +560,18 @@ | |
| validators=[validate_repoweb], | ||
| blank=True, | ||
| ) | ||
| repoweb_translations = models.CharField( | ||
| verbose_name=gettext_lazy("Repository browser for translations"), | ||
| max_length=200, | ||
| help_text=gettext_lazy( | ||
| "Link to repository browser for translation files, use {{branch}} for branch, " | ||
| "{{filename}} and {{line}} as filename and line placeholders. " | ||
| "If left empty, the Repository browser above will be used. " | ||
| "You might want to strip leading directory by using {{filename|parentdir}}." | ||
| ), | ||
| validators=[validate_repoweb], | ||
| blank=True, | ||
| ) | ||
| git_export = models.CharField( | ||
| verbose_name=gettext_lazy("Exported repository URL"), | ||
| max_length=60 + PROJECT_NAME_LENGTH + COMPONENT_NAME_LENGTH, | ||
|
|
@@ -920,7 +932,7 @@ | |
| ), | ||
| ) | ||
|
|
||
| links = models.ManyToManyField( | ||
| "trans.Project", | ||
| verbose_name=gettext_lazy("Share in projects"), | ||
| blank=True, | ||
|
|
@@ -1445,7 +1457,7 @@ | |
| # Calculate progress for translations | ||
| if progress is None: | ||
| self.translations_progress += 1 | ||
| progress = 100 * self.translations_progress // self.translations_count | ||
| # Store task state | ||
| current_task.update_state( | ||
| state="PROGRESS", meta={"progress": progress, "component": self.pk} | ||
|
|
@@ -1487,7 +1499,7 @@ | |
| if "source_translation" in self.__dict__: | ||
| return self.__dict__["source_translation"] | ||
| try: | ||
| result = self.translation_set.get(language_id=self.source_language_id) | ||
| except ObjectDoesNotExist: | ||
| return None | ||
| result.sync_readonly_check_flag() | ||
|
|
@@ -1530,7 +1542,7 @@ | |
| ) | ||
| except IntegrityError: | ||
| try: | ||
| result = self.translation_set.get( | ||
| language_id=self.source_language_id | ||
| ) | ||
| except self.translation_set.model.DoesNotExist: | ||
|
|
@@ -1566,7 +1578,7 @@ | |
|
|
||
| def _process_new_source(self, source: Unit, *, save: bool = True) -> Change: | ||
| # Avoid fetching empty list of checks from the database | ||
| source.all_checks = [] | ||
| source.source_updated = True | ||
| change = source.generate_change( | ||
| self.acting_user, | ||
|
|
@@ -1846,6 +1858,7 @@ | |
| line: str, | ||
| template: str | None = None, | ||
| user: User | None = None, | ||
| is_translation: bool = False, | ||
| ): | ||
| """ | ||
| Generate link to source code browser for given file and line. | ||
|
|
@@ -1854,7 +1867,9 @@ | |
| here. | ||
| """ | ||
|
Comment on lines
1863
to
1868
|
||
| if not template: | ||
| if self.repoweb: | ||
| if is_translation and self.repoweb_translations: | ||
| template = self.repoweb_translations | ||
| elif self.repoweb: | ||
| template = self.repoweb | ||
| elif user and user.has_perm("vcs.view", self): | ||
|
Comment on lines
1869
to
1874
|
||
| template = getattr( | ||
|
|
@@ -3215,7 +3230,7 @@ | |
|
|
||
| def clear_prefetched_alerts(self) -> None: | ||
| with suppress(AttributeError, KeyError): | ||
| self._prefetched_objects_cache.pop("alert_set") | ||
|
|
||
| @property | ||
| def lock_alerts(self): | ||
|
|
@@ -3378,7 +3393,7 @@ | |
| if self.has_template(): | ||
| # Avoid parsing if template is invalid | ||
| try: | ||
| self.template_store.check_valid() | ||
| except (ValueError, FileParseError) as exc: | ||
| raise InvalidTemplateError(info=str(exc)) from exc | ||
| self._template_check_done = True | ||
|
|
@@ -3442,7 +3457,7 @@ | |
| if ( | ||
| self.file_format == "po" | ||
| and self.new_base.endswith(".pot") | ||
| and os.path.exists(self.get_new_base_filename()) | ||
| ): | ||
| # Process pot file as source to include additional metadata | ||
| matches = [self.new_base, *matches] | ||
|
|
@@ -3511,7 +3526,7 @@ | |
| ) | ||
| self.handle_parse_error(error.__cause__, filename=self.template) | ||
| self.update_import_alerts() | ||
| raise error.__cause__ from error # pylint: disable=raising-non-exception | ||
| was_change |= bool(translation.reason) | ||
| translations[translation.id] = translation | ||
| languages[lang.code] = translation | ||
|
|
@@ -3858,7 +3873,7 @@ | |
| filename = self.get_new_base_filename() | ||
| template = self.has_template() | ||
| return self.file_format_cls.is_valid_base_for_new( | ||
| filename, | ||
| template, | ||
| errors, | ||
| fast=fast, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.