Skip to content

Commit

Permalink
Form code of plugins optimized
Browse files Browse the repository at this point in the history
  • Loading branch information
matejak committed Apr 18, 2024
1 parent 31b8162 commit 9711e38
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 52 deletions.
4 changes: 3 additions & 1 deletion estimage/plugins/crypto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
from ...webapp import web_utils
from ...entities import status
from ...visualize.burndown import StatusStyle
from .forms import CryptoForm, ProblemForm
from .forms import CryptoForm
from ..jira.forms import AuthoritativeForm, ProblemForm


EXPORTS = dict(
AuthoritativeForm="AuthoritativeForm",
ProblemForm="ProblemForm",
MPLPointPlot="MPLPointPlot",
Statuses="Statuses",
Expand Down
4 changes: 0 additions & 4 deletions estimage/plugins/crypto/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ class CryptoFormEnd(BaseForm):

class CryptoForm(forms.EncryptedTokenForm, CryptoFormEnd):
pass


class ProblemForm(forms.EncryptedTokenForm):
pass
27 changes: 27 additions & 0 deletions estimage/plugins/jira/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,30 @@ class JiraFormEnd(BaseForm):

class JiraForm(JiraFormStart, EncryptedTokenForm, JiraFormEnd):
pass


class AuthoritativeForm(EncryptedTokenForm):
token = wtforms.PasswordField('Jira Token')

def clear_to_go(self):
self.enable_submit_button()
super().clear_to_go()

def __iter__(self):
attributes = (
self.csrf_token,
self.task_name,
self.point_cost,
self.token,
self.store_token,
self.i_kid_you_not,
self.encrypted_token,
self.encrypted_meant_for_storage,
self.submit,
)
ret = (a for a in attributes)
return ret


class ProblemForm(EncryptedTokenForm):
pass
2 changes: 1 addition & 1 deletion estimage/plugins/redhat_compliance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ...webapp import web_utils
from ...visualize.burndown import StatusStyle
from .. import jira
from .forms import AuthoritativeForm, ProblemForm
from ..jira.forms import AuthoritativeForm, ProblemForm


EXPORTS = dict(
Expand Down
46 changes: 0 additions & 46 deletions estimage/plugins/redhat_compliance/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,3 @@ class RedhatComplianceFormEnd(BaseForm):

class RedhatComplianceForm(forms.EncryptedTokenForm, RedhatComplianceFormEnd):
pass


class RedhatComplianceRefreshForm(BaseForm):

def request_refresh_of(self, names):
self.cards.data = ",".join(names)
if len(names) == 1:
self.submit.label.text = "Refresh item"
elif (count := len(names)) > 1:
self.submit.label.text = f"Refresh total {count} items"

def get_what_names_to_refresh(self):
return self.cards.data.split(",")

token = wtforms.PasswordField('Token')
mode = wtforms.HiddenField('retro_or_proj')
cards = wtforms.HiddenField('csv')
next = wtforms.HiddenField('url')
submit = wtforms.SubmitField("Refresh")


class AuthoritativeForm(forms.EncryptedTokenForm):
token = wtforms.PasswordField('Jira Token')

def clear_to_go(self):
self.enable_submit_button()
super().clear_to_go()

def __iter__(self):
attributes = (
self.csrf_token,
self.task_name,
self.point_cost,
self.token,
self.store_token,
self.i_kid_you_not,
self.encrypted_token,
self.encrypted_meant_for_storage,
self.submit,
)
ret = (a for a in attributes)
return ret


class ProblemForm(forms.EncryptedTokenForm):
pass

0 comments on commit 9711e38

Please sign in to comment.