-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TRAC #7528 Adds challenge update form
- Loading branch information
Showing
10 changed files
with
173 additions
and
38 deletions.
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,19 +1,106 @@ | ||
from crispy_forms.bootstrap import TabHolder, Tab | ||
from crispy_forms.helper import FormHelper | ||
from crispy_forms.layout import Submit | ||
from crispy_forms.layout import Submit, Layout, ButtonHolder | ||
from django import forms | ||
|
||
from comicmodels.models import ComicSite | ||
|
||
|
||
class ChallengeForm(forms.ModelForm): | ||
class ChallengeCreateForm(forms.ModelForm): | ||
def __init__(self, *args, **kwargs): | ||
super(ChallengeForm, self).__init__(*args, **kwargs) | ||
super().__init__(*args, **kwargs) | ||
self.helper = FormHelper(self) | ||
self.helper.layout.append(Submit('save', 'Save')) | ||
|
||
class Meta: | ||
model = ComicSite | ||
fields = ['short_name', | ||
'description', | ||
'require_participant_review', | ||
'use_evaluation'] | ||
fields = [ | ||
'short_name', | ||
'description', | ||
'require_participant_review', | ||
'use_evaluation', | ||
] | ||
|
||
|
||
class ChallengeUpdateForm(forms.ModelForm): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.helper = FormHelper(self) | ||
self.helper.layout = Layout( | ||
TabHolder( | ||
Tab( | ||
'Information', | ||
'title', | ||
'description', | ||
'logo', | ||
), | ||
Tab( | ||
'Layout', | ||
'header_image', | ||
'skin', | ||
'disclaimer', | ||
), | ||
Tab( | ||
'Metadata', | ||
'workshop_date', | ||
'event_name', | ||
'event_url', | ||
'is_open_for_submissions', | ||
'submission_page_name', | ||
'number_of_submissions', | ||
'last_submission_date', | ||
'offers_data_download', | ||
'number_of_downloads', | ||
'publication_url', | ||
'publication_journal_name', | ||
), | ||
Tab( | ||
'Users', | ||
'use_registration_page', | ||
'require_participant_review', | ||
'registration_page_text', | ||
), | ||
Tab( | ||
'Visibility', | ||
'hidden', | ||
'hide_signin', | ||
'hide_footer', | ||
), | ||
Tab( | ||
'Automated Evaluation', | ||
'use_evaluation', | ||
), | ||
), | ||
ButtonHolder( | ||
Submit('save', 'Save'), | ||
) | ||
) | ||
|
||
class Meta: | ||
model = ComicSite | ||
fields = [ | ||
'title', | ||
'description', | ||
'logo', | ||
'header_image', | ||
'skin', | ||
'disclaimer', | ||
'workshop_date', | ||
'event_name', | ||
'event_url', | ||
'is_open_for_submissions', | ||
'submission_page_name', | ||
'number_of_submissions', | ||
'last_submission_date', | ||
'offers_data_download', | ||
'number_of_downloads', | ||
'publication_url', | ||
'publication_journal_name', | ||
'use_registration_page', | ||
'require_participant_review', | ||
'registration_page_text', | ||
'hidden', | ||
'hide_signin', | ||
'hide_footer', | ||
'use_evaluation', | ||
] |
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,14 +1,18 @@ | ||
{% extends "mainpage.html" %} | ||
{% load crispy_forms_tags %} | ||
{% load static from staticfiles %} | ||
|
||
{% block pageName %}New Challenge{% endblock %} | ||
|
||
{% block pagecontent %} | ||
{% block contentTitle %} | ||
<h2>Create A New Challenge</h2> | ||
|
||
<p> | ||
Please fill out this form if you would like to set up your own challenge. | ||
</p> | ||
{% endblock %} | ||
|
||
{% block pagecontent %} | ||
{% crispy form %} | ||
|
||
<script type="text/javascript" src="{% static "js/unsavedform.js" %}"></script> | ||
{% endblock %} |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% extends 'comicmodels/comicsite_form.html' %} | ||
|
||
{% block contentTitle %} | ||
<h2>Update {{ site.short_name }}</h2> | ||
{% endblock %} |
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,10 @@ | ||
from django.conf.urls import url | ||
|
||
from challenges.views import ChallengeCreate, ChallengeList | ||
from challenges.views import ChallengeCreate, ChallengeList, ChallengeUpdate | ||
|
||
urlpatterns = [ | ||
url(r'^my-challenges/$', ChallengeList.as_view(), name='list'), | ||
url(r'^create/$', ChallengeCreate.as_view(), name='create'), | ||
url(r'^(?P<challenge_short_name>[\w-]+)/update/$', | ||
ChallengeUpdate.as_view(), name='update') | ||
] |
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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
$(document).ready(function () { | ||
var unsaved = false; | ||
|
||
$(":input").change(function () { | ||
unsaved = true; | ||
}); | ||
|
||
function unloadPage() { | ||
if (unsaved) { | ||
return "You have unsaved changes on this page. Do you want to leave this page and discard your changes or stay on this page?"; | ||
} | ||
} | ||
|
||
window.onbeforeunload = unloadPage; | ||
}); |
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