-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
214 additions
and
28 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
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,31 @@ | ||
from django.test import TestCase | ||
from django.forms.fields import DateTimeField | ||
from viewflow.site.templatetags import viewform | ||
|
||
|
||
class TestDatePickerFormatFilter(TestCase): | ||
def test_format_translation(self): | ||
translations = { | ||
'%Y-%m-%d': 'yyyy-mm-dd', | ||
'%m/%d/%Y': 'mm/dd/yyyy', | ||
'%m/%d/%y': 'mm/dd/yy', | ||
'%b %d %Y': 'M dd yyyy', | ||
'%b %d, %Y': 'M dd, yyyy', | ||
'%d %b %Y': 'dd M yyyy', | ||
'%d %b, %Y': 'dd M, yyyy', | ||
'%B %d %Y': 'MM dd yyyy', | ||
'%B %d, %Y': 'MM dd, yyyy', | ||
'%d %B %Y': 'dd MM yyyy', | ||
'%d %B, %Y': 'dd MM, yyyy', | ||
'%Y-%m-%d %H:%M:%S': 'yyyy-mm-dd hh:ii:ss', | ||
'%Y-%m-%d %H:%M': 'yyyy-mm-dd hh:ii', | ||
'%m/%d/%Y %H:%M:%S': 'mm/dd/yyyy hh:ii:ss', | ||
'%m/%d/%Y %H:%M': 'mm/dd/yyyy hh:ii', | ||
'%m/%d/%y %H:%M:%S': 'mm/dd/yy hh:ii:ss', | ||
'%m/%d/%y %H:%M': 'mm/dd/yy hh:ii', | ||
} | ||
|
||
for input_format, output_format in translations.items(): | ||
field = DateTimeField(input_formats=[input_format]) | ||
result = viewform.datepicker_format(field) | ||
self.assertEquals(output_format, result) |
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
41 changes: 36 additions & 5 deletions
41
viewflow/site/templates/viewflow/form/bootstrap3/widgets/dateinput.html
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,7 +1,38 @@ | ||
<div class="form-group"> | ||
<label for="dtp_input2" class="control-label">Date Picking</label> | ||
<div class="input-group date" data-date="" data-date-format="dd/mm/yyyy" data-min-view="2" data-viewform-control="date"> | ||
<input class="form-control" size="16" type="text" value=""> | ||
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span> | ||
{% load viewform %} | ||
<div {% tagattrs %} | ||
class="{% viewpart field group_class %} | ||
form-group | ||
{% if field.required%}required{% endif %} | ||
{% if bound_field.errors %}has-error{% endif %} | ||
{% viewpart field add_group_class %}{% endviewpart %} | ||
{% endviewpart %}"{% endtagattrs %}> | ||
{% viewpart field label %} | ||
<label for="{{ bound_field.id_for_label }}" class="control-label">{{ bound_field.label }}</label> | ||
{% endviewpart %} | ||
<div class="input-group" style="width:100%"> | ||
<div {% tagattrs %} | ||
class="input-group date" | ||
data-date-format="{{ field|datepicker_format }}" | ||
data-min-view="2" | ||
data-viewform-control="date"{% endtagattrs %}{% if bound_field.value %} data_date="{{ bound_field|datepicker_value }}"{% endif %}> | ||
{% viewpart field prepend %}{% endviewpart %}{% viewpart field control %} | ||
<input {% tagattrs %} | ||
type="{{ field.widget.input_type }}" | ||
class="form-control" | ||
name="{{ bound_field.html_name }}" | ||
id="id_{{ bound_field.html_name }}"{% endtagattrs %}{% if bound_field.value %} value="{{ bound_field|datepicker_value }}"{% endif %}> | ||
{% endviewpart %}{% viewpart field append %} | ||
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span> | ||
{% endviewpart %} | ||
</div> | ||
</div> | ||
{% viewpart field errors %} | ||
{% if bound_field.errors %} | ||
{% include 'viewflow/form/bootstrap3/field_errors.html' %} | ||
{% endif %} | ||
{% endviewpart %}{% viewpart field help_text %} | ||
{% if field.help_text %} | ||
<span class="help-block">{{ bound_field.help_text }}</span> | ||
{% endif %} | ||
{% endviewpart %}{{ hidden_initial }} | ||
</div> |
41 changes: 36 additions & 5 deletions
41
viewflow/site/templates/viewflow/form/bootstrap3/widgets/datetimeinput.html
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,7 +1,38 @@ | ||
<div class="form-group"> | ||
<label for="dtp_input2" class="control-label">DateTime Picking</label> | ||
<div class="input-group date" data-date="" data-date-format="dd/mm/yyyy hh:ii" data-min-view="0" data-viewform-control="datetime"> | ||
<input class="form-control" size="16" type="text" value=""> | ||
<span class="input-group-addon"> <span class="glyphicon glyphicon-time"></span> </span> | ||
{% load viewform %} | ||
<div {% tagattrs %} | ||
class="{% viewpart field group_class %} | ||
form-group | ||
{% if field.required%}required{% endif %} | ||
{% if bound_field.errors %}has-error{% endif %} | ||
{% viewpart field add_group_class %}{% endviewpart %} | ||
{% endviewpart %}"{% endtagattrs %}> | ||
{% viewpart field label %} | ||
<label for="{{ bound_field.id_for_label }}" class="control-label">{{ bound_field.label }}</label> | ||
{% endviewpart %} | ||
<div class="input-group" style="width:100%"> | ||
<div {% tagattrs %} | ||
class="input-group date" | ||
data-date-format="{{ field|datepicker_format }}" | ||
data-min-view="0" | ||
data-viewform-control="datetime"{% endtagattrs %}{% if bound_field|datepicker_value %} data_date="{{ bound_field.value }}"{% endif %}> | ||
{% viewpart field prepend %}{% endviewpart %}{% viewpart field control %} | ||
<input {% tagattrs %} | ||
type="{{ field.widget.input_type }}" | ||
class="form-control" | ||
name="{{ bound_field.html_name }}" | ||
id="id_{{ bound_field.html_name }}"{% endtagattrs %}{% if bound_field.value %} value="{{ bound_field|datepicker_value }}"{% endif %}> | ||
{% endviewpart %}{% viewpart field append %} | ||
<span class="input-group-addon"><span class="glyphicon glyphicon-time" style="font-weight:bold"></span></span> | ||
{% endviewpart %} | ||
</div> | ||
</div> | ||
{% viewpart field errors %} | ||
{% if bound_field.errors %} | ||
{% include 'viewflow/form/bootstrap3/field_errors.html' %} | ||
{% endif %} | ||
{% endviewpart %}{% viewpart field help_text %} | ||
{% if field.help_text %} | ||
<span class="help-block">{{ bound_field.help_text }}</span> | ||
{% endif %} | ||
{% endviewpart %}{{ hidden_initial }} | ||
</div> |
27 changes: 26 additions & 1 deletion
27
viewflow/site/templates/viewflow/form/bootstrap3/widgets/fileinput.html
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 +1,26 @@ | ||
fileinput | ||
{% load viewform %} | ||
<div {% tagattrs %} | ||
class="{% viewpart field group_class %} | ||
form-group | ||
{% if field.required%}required{% endif %} | ||
{% if bound_field.errors %}has-error{% endif %} | ||
{% viewpart field add_group_class %}{% endviewpart %} | ||
{% endviewpart %}"{% endtagattrs %}> | ||
{% viewpart field label %} | ||
<label for="{{ bound_field.id_for_label }}" class="control-label">{{ bound_field.label }}</label> | ||
{% endviewpart %} | ||
<div class="input-group" style="width:100%"> | ||
{% viewpart field prepend %}{% endviewpart %}{% viewpart field control %} | ||
{{ bound_field }} | ||
{% endviewpart %}{% viewpart field append %}{% endviewpart %} | ||
</div> | ||
{% viewpart field errors %} | ||
{% if bound_field.errors %} | ||
{% include 'viewflow/form/bootstrap3/field_errors.html' %} | ||
{% endif %} | ||
{% endviewpart %}{% viewpart field help_text %} | ||
{% if field.help_text %} | ||
<span class="help-block">{{ bound_field.help_text }}</span> | ||
{% endif %} | ||
{% endviewpart %}{{ hidden_initial }} | ||
</div> |
41 changes: 36 additions & 5 deletions
41
viewflow/site/templates/viewflow/form/bootstrap3/widgets/timeinput.html
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,7 +1,38 @@ | ||
<div class="form-group"> | ||
<label for="dtp_input2" class="control-label">Time Picking</label> | ||
<div class="input-group date" data-date="" data-date-format="hh:ii" data-start-view="1" data-viewform-control="time"> | ||
<input class="form-control" size="16" type="text" value=""> | ||
<span class="input-group-addon"><span class="glyphicon glyphicon-time"></span></span> | ||
{% load viewform %} | ||
<div {% tagattrs %} | ||
class="{% viewpart field group_class %} | ||
form-group | ||
{% if field.required%}required{% endif %} | ||
{% if bound_field.errors %}has-error{% endif %} | ||
{% viewpart field add_group_class %}{% endviewpart %} | ||
{% endviewpart %}"{% endtagattrs %}> | ||
{% viewpart field label %} | ||
<label for="{{ bound_field.id_for_label }}" class="control-label">{{ bound_field.label }}</label> | ||
{% endviewpart %} | ||
<div class="input-group" style="width:100%"> | ||
<div {% tagattrs %} | ||
class="input-group date" | ||
data-date-format="{{ field|datepicker_format }}" | ||
data-start-view="1" | ||
data-viewform-control="time"{% endtagattrs %}{% if bound_field.value %} data_date="{{ bound_field|datepicker_value }}"{% endif %}> | ||
{% viewpart field prepend %}{% endviewpart %}{% viewpart field control %} | ||
<input {% tagattrs %} | ||
type="{{ field.widget.input_type }}" | ||
class="form-control" | ||
name="{{ bound_field.html_name }}" | ||
id="id_{{ bound_field.html_name }}"{% endtagattrs %}{% if bound_field.value %} value="{{ bound_field|datepicker_value }}"{% endif %}> | ||
{% endviewpart %}{% viewpart field append %} | ||
<span class="input-group-addon"><span class="glyphicon glyphicon-time"></span></span> | ||
{% endviewpart %} | ||
</div> | ||
</div> | ||
{% viewpart field errors %} | ||
{% if bound_field.errors %} | ||
{% include 'viewflow/form/bootstrap3/field_errors.html' %} | ||
{% endif %} | ||
{% endviewpart %}{% viewpart field help_text %} | ||
{% if field.help_text %} | ||
<span class="help-block">{{ bound_field.help_text }}</span> | ||
{% endif %} | ||
{% endviewpart %}{{ hidden_initial }} | ||
</div> |
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