-
Notifications
You must be signed in to change notification settings - Fork 61
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
frontend: use common enum constants for sharing descriptions #3030
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,56 @@ | ||
""" | ||
File which contains only constants. Nothing else. | ||
""" | ||
|
||
from collections import namedtuple | ||
from enum import Enum | ||
from typing import Any | ||
|
||
BANNER_LOCATION = "/var/lib/copr/data/banner-include.html" | ||
|
||
DEFAULT_COPR_REPO_PRIORITY = 99 | ||
|
||
|
||
CommonAttribute = namedtuple( | ||
"CommonAttribute", ["description", "default"], defaults=("", None) | ||
) | ||
|
||
|
||
# just shortcut | ||
c = CommonAttribute # pylint: disable=invalid-name | ||
|
||
|
||
# Common descriptions for forms, fields, etc. | ||
class CommonDescriptions(Enum): | ||
""" | ||
Enumerator for common descriptions and their default value between forms, | ||
fields, etc. | ||
""" | ||
ADDITIONAL_PACKAGES = c( | ||
"Additional packages to be always present in minimal buildroot" | ||
) | ||
MOCK_CHROOT = c("Mock chroot", "fedora-latest-x86_64") | ||
ADDITIONAL_REPOS = c("Additional repos to be used for builds in this chroot") | ||
ENABLE_NET = c("Enable internet access during builds") | ||
PYPI_PACKAGE_NAME = c("Package name in the Python Package Index") | ||
PYPI_PACKAGE_VERSION = c("PyPI package version") | ||
SPEC_GENERATOR = c( | ||
"Tool for generating specfile from a PyPI package. " | ||
"The options are full-featured pyp2rpm with cross " | ||
"distribution support, and pyp2spec that is being actively " | ||
"developed and considered to be the future." | ||
) | ||
AUTO_REBUILD = c("Auto-rebuild the package? (i.e. every commit or new tag)") | ||
|
||
@property | ||
def description(self) -> str: | ||
""" | ||
Get description of Enum member | ||
""" | ||
return self.value.description | ||
|
||
@property | ||
def default(self) -> Any: | ||
""" | ||
Fet default value of Enum member | ||
""" | ||
return self.value.default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,14 +37,14 @@ <h3 class="panel-title">{{ counter('instructions') }}. Provide the source</h3> | |
</form> | ||
{% endmacro %} | ||
|
||
{% macro render_webhook_rebuild(form) %} | ||
{% macro render_webhook_rebuild(form, common_descriptions) %} | ||
<div class="form-group"> | ||
<label class="col-sm-2 control-label" for="textInput-markup"> | ||
Auto-rebuild | ||
</label> | ||
<div class="col-sm-10"> | ||
<input type="checkbox" name="webhook_rebuild" {% if form.webhook_rebuild.data == True %}checked="checked"{% endif %}/> | ||
Auto-rebuild the package? (i.e. every commit or new tag) | ||
{{ common_descriptions.SPEC_GENERATOR.description }} | ||
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. Only part of the message is moved here. |
||
| See <a href="{{ copr_url('coprs_ns.copr_integrations', copr) }}">Integrations</a> | ||
</div> | ||
</div> | ||
|
@@ -88,7 +88,7 @@ <h3 class="panel-title">{{ counter('instructions') }}. Generic package setup</h3 | |
|
||
{% macro copr_package_form_pypi(form, view, copr, package) %} | ||
{{ copr_package_form_begin(form, view, copr, package) }} | ||
{{ render_field(form.pypi_package_name, placeholder="Package name in the Python Package Index.") }} | ||
{{ render_field(form.pypi_package_name, placeholder="{{ common_descriptions.PYPI_PACKAGE_NAME.description }}.") }} | ||
|
||
{{ render_field( | ||
form.spec_generator, | ||
|
@@ -132,11 +132,11 @@ <h3 class="panel-title"> | |
{% endmacro %} | ||
|
||
|
||
{% macro copr_package_form_custom(form, view, copr, package) %} | ||
{% macro copr_package_form_custom(form, view, copr, package, common_descriptions) %} | ||
{{ copr_package_form_begin(form, view, copr, package) }} | ||
{{ copr_method_form_fileds_custom(form) }} | ||
{{ render_generic_pkg_form(form) }} | ||
{{ render_webhook_rebuild(form) }} | ||
{{ render_webhook_rebuild(form, common_descriptions) }} | ||
{{ copr_package_form_end(form, package, 'custom') }} | ||
{% endmacro %} | ||
|
||
|
@@ -164,7 +164,7 @@ <h3 class="panel-title"> | |
{% endmacro %} | ||
|
||
|
||
{% macro copr_package_form_scm(form, view, copr, package) %} | ||
{% macro copr_package_form_scm(form, view, copr, package, common_descriptions) %} | ||
{{ copr_package_form_begin(form, view, copr, package) }} | ||
|
||
{{ render_field(form.scm_type) }} | ||
|
@@ -175,7 +175,7 @@ <h3 class="panel-title"> | |
|
||
{{ render_srpm_build_method_box(form) }} | ||
{{ render_generic_pkg_form(form) }} | ||
{{ render_webhook_rebuild(form) }} | ||
{{ render_webhook_rebuild(form, common_descriptions) }} | ||
{{ copr_package_form_end(form, package, 'mock_scm') }} | ||
{% endmacro %} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we are losing formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also note there are some form field metdata arguments we could perhaps use:
copr/frontend/coprs_frontend/coprs/forms.py
Lines 581 to 584 in 0b7d458
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's true... perhaps this one is worth not unifying