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

Add datepicker #224

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 7 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ unzip \
$BOOTSTRAP_ZIP \
-d $TMP_FOLDER

# jQuery
mkdir -p $TMP_FOLDER/jquery/js
curl \
-L \
-o $TMP_FOLDER/jquery/js/jquery.min.js \
https://code.jquery.com/jquery-3.1.1.min.js

# Font Awesome
curl \
-L \
Expand Down
42 changes: 27 additions & 15 deletions lowfat/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from crispy_forms.layout import Layout, Fieldset, ButtonHolder, Submit, HTML
from crispy_forms.bootstrap import PrependedText

from bootstrap3_datetime.widgets import DateTimePicker

from .models import *

TODAY_YEAR = datetime.now().year
Expand Down Expand Up @@ -177,13 +179,17 @@ class Meta:
}

widgets = {
'start_date': SelectDateWidget(
years=SELECT_DATE_WIDGE_YEARS,
empty_label=("Choose Year", "Choose Month", "Choose Day")
'start_date': DateTimePicker(
options={
"format": "YYYY-MM-DD",
"pickTime": False
}
),
'end_date': SelectDateWidget(
years=SELECT_DATE_WIDGE_YEARS,
empty_label=("Choose Year", "Choose Month", "Choose Day")
'end_date': DateTimePicker(
options={
"format": "YYYY-MM-DD",
"pickTime": False
}
),
}

Expand Down Expand Up @@ -384,17 +390,23 @@ class Meta:
]

widgets = {
'received_date': SelectDateWidget(
years=SELECT_DATE_WIDGE_YEARS,
empty_label=("Choose Year", "Choose Month", "Choose Day")
'received_date': DateTimePicker(
options={
"format": "YYYY-MM-DD",
"pickTime": False
}
),
'asked_for_authorization_date': SelectDateWidget(
years=SELECT_DATE_WIDGE_YEARS,
empty_label=("Choose Year", "Choose Month", "Choose Day")
'asked_for_authorization_date': DateTimePicker(
options={
"format": "YYYY-MM-DD",
"pickTime": False
}
),
'send_to_finance_date': SelectDateWidget(
years=SELECT_DATE_WIDGE_YEARS,
empty_label=("Choose Year", "Choose Month", "Choose Day")
'send_to_finance_date': DateTimePicker(
options={
"format": "YYYY-MM-DD",
"pickTime": False
}
),
}

Expand Down
1 change: 1 addition & 0 deletions lowfat/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
'django.contrib.flatpages',
'django_countries',
'crispy_forms',
'bootstrap3_datetime',
'social_django',
'dbbackup',
'constance',
Expand Down
6 changes: 6 additions & 0 deletions lowfat/templates/lowfat/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@
<link rel="stylesheet" type="text/css" href="{% static 'css/font-awesome.min.css' %}"/>
<link rel="stylesheet" type="text/css" href="{% static 'css/academicons.css' %}"/>

<!-- jQuery -->
<script src="{% static 'js/jquery.min.js' %}"></script>

<!-- Sorttable -->
<script src="{% static 'js/sorttable.js' %}"></script>

<!-- Custom -->
<link rel="stylesheet" type="text/css" href="{% static 'css/lowfat.css' %}" />

<!-- Required by django-bootstrap3-datetimepicker -->
{{ form.media }}

{% block extra_css %}{% endblock %}
{% block extra_js %}{% endblock %}
{% for js in js_files %}
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
bokeh
django
django-backup
django-bootstrap3-datetimepicker
django-constance[database]
django-countries
django-crispy-forms
Expand Down