Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Final touches of Call For Proposals feature #328

Merged
merged 2 commits into from
Sep 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions busy_beaver/apps/call_for_proposals/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@
from wtforms.fields import FieldList, FormField, SelectField, StringField
from wtforms.fields.html5 import URLField
from wtforms.validators import URL, DataRequired
from wtforms.widgets import HTMLString, html_params


class RemoveButtonWidget(object):
input_type = "submit"

html_params = staticmethod(html_params)

def __call__(self, field, **kwargs):
kwargs.setdefault("id", field.id)
kwargs.setdefault("type", "button")
if "value" not in kwargs:
kwargs["value"] = field._value()

kwargs["class"] = "remove form-control"
return HTMLString(
"<button {params}>{label}</button>".format(
params=self.html_params(name=field.name, **kwargs), label="X"
)
)


class RemoveButtonField(StringField):
widget = RemoveButtonWidget()


class InternalCFPItemForm(FlaskForm):
Expand All @@ -10,6 +34,7 @@ class Meta:

event = StringField(validators=[DataRequired()])
url = URLField("CFP URL", validators=[URL()])
remove = RemoveButtonField("remove")


class CFPSettingsForm(FlaskForm):
Expand Down
10 changes: 2 additions & 8 deletions busy_beaver/templates/cfp_settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ <h3>Configure Call For Proposals Feature</h3>
{% for subform in form.internal_cfps %}
<div id="internal-cfp-{{ loop.index0 }}-form" class="subform" data-index="{{ loop.index0 }}">
{{ subform.csrf_token }}
{{ render_form_row([subform.event, subform.url], col_map={subform.event.id: 'col-md-3', subform.url.id: 'col-md-9'}) }}
<small>
<a class="remove" href="#">Remove</a>
</small>
{{ render_form_row([subform.event, subform.url, subform.remove], col_map={subform.event.id: 'col-md-3', subform.url.id: 'col-md-8', subform.remove.id: 'col-md-1'}) }}
</div>
{% endfor %}
</div>
Expand All @@ -58,10 +55,7 @@ <h3>Configure Call For Proposals Feature</h3>
{# hidden template used to generate new rows #}
{% for subform in template_form.internal_cfps[:1] %}
<div id="template-internal-cfp-_-form" class="is-hidden" data-index="_">
{{ render_form_row([subform.event, subform.url], col_map={subform.event.id: 'col-md-3', subform.url.id: 'col-md-9'}) }}
<small>
<a class="remove" href="#">Remove</a>
</small>
{{ render_form_row([subform.event, subform.url, subform.remove], col_map={subform.event.id: 'col-md-3', subform.url.id: 'col-md-8', subform.remove.id: 'col-md-1'}) }}
</div>
{% endfor %}

Expand Down
25 changes: 25 additions & 0 deletions helm/charts/busybeaver/templates/cronjob--post-upcoming-cfps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: "{{ include "busybeaver.fullname" . }}--post-upcoming-cfps"
namespace: "{{ include "busybeaver.namespace" . }}"
labels:
type: sync-events-database
{{- include "busybeaver.labels" . | nindent 4 }}
spec:
schedule: "0 12 * * 1"
jobTemplate:
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: busybeaver--post-upcoming-cfps
image: {{ .Values.image.repository }}:{{ .Values.image.version }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["flask"]
args:
- "post_upcoming_cfps"
env: {{- include "busybeaver.env_vars" . | indent 12 }}
serviceAccountName: {{ include "busybeaver.serviceAccountName" . }}
automountServiceAccountToken: false