Skip to content
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

added optional resource name for workflows #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ def render_condor_jobs_table(self, request, session, workflow, current_step, pre
# Get the current app
step_url_name = self.get_step_url_name(request, workflow)

if workflow.resource_name:
nav_title = f'{workflow.resource_name}: {workflow.name}'
else:
nav_title = workflow.name

context = {
'workflow': workflow,
'steps': steps,
Expand All @@ -129,7 +134,7 @@ def render_condor_jobs_table(self, request, session, workflow, current_step, pre
'finish_title': self.finish_title,
'previous_title': self.previous_title,
'back_url': self.back_url,
'nav_title': workflow.name,
'nav_title': nav_title,
'nav_subtitle': workflow.DISPLAY_TYPE_SINGULAR,
'jobs_table': jobs_table,
'base_template': self.base_template
Expand Down
8 changes: 7 additions & 1 deletion tethysext/workflows/controllers/workflows/workflow_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,20 @@ def get_context(self, request, session, context, workflow_id, step_id, *args, **
# Get the current app
step_url_name = self.get_step_url_name(request, workflow)


if workflow.resource_name:
nav_title = f'{workflow.resource_name}: {workflow.name}'
else:
nav_title = workflow.name

context.update({
'workflow': workflow,
'steps': steps,
'current_step': current_step,
'previous_step': previous_step,
'next_step': next_step,
'step_url_name': step_url_name,
'nav_title': 'Replacement Resource Name: replacement workflow name',
'nav_title': nav_title,
'nav_subtitle': workflow.DISPLAY_TYPE_SINGULAR,
'previous_title': self.previous_title,
'next_title': self.next_title,
Expand Down
1 change: 1 addition & 0 deletions tethysext/workflows/models/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class TethysWorkflow(WorkflowsBase, AttributesMixin, ResultsMixin):
name = Column(String)
date_created = Column(DateTime, default=dt.datetime.utcnow)
_attributes = Column(String)
resource_name = Column(String, nullable=True)

steps = relationship('Step', order_by='Step.order', backref='workflow',
cascade='all,delete')
Expand Down
4 changes: 4 additions & 0 deletions tethysext/workflows/templates/gizmos/new_workflow_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ <h4 class="modal-title" id="new-workflow-modal-label">New Workflow</h4>
{% endfor %}
</select>
</div>
<div class="form-group">
<label for="new-workflow-resource-input">Resource Name (Optional)</label>
<input type="text" class="form-control" id="new-workflow-resource-input" name="resource-name">
</div>
</form>
</div>
<div class="modal-footer">
Expand Down
2 changes: 2 additions & 0 deletions tethysext/workflows/views/layouts/workflow_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def post(self, request, *args, **kwargs):
if 'new-workflow' in params:
workflow_name = params.get('workflow-name')
workflow_type = params.get('workflow-type')
resource_name = params.get('resource-name', None)

if not workflow_name:
messages.error(request, 'Unable to create new workflow: no name given.')
Expand All @@ -173,6 +174,7 @@ def post(self, request, *args, **kwargs):
workflow = workflow_model.new(
app=self.app,
name=workflow_name,
resource_name=resource_name,
creator_id = request.user.id,
creator_name = request.user.username,
geoserver_name = self.app.GEOSERVER_NAME,
Expand Down