Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 76ff48c

Browse files
committed
AdminFileInput link. Close viewflow#288. Close viewflow#289
1 parent 4c6ff6f commit 76ff48c

8 files changed

Lines changed: 67 additions & 5 deletions

File tree

demo/templates/admin_demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
{% block head %}
77
{% include 'admin/includes/material_css.html' %}
8-
<script src="{% static 'material/js/jquery-2.2.0.js' %}"></script>
8+
<script src="{% static 'material/js/jquery.js' %}"></script>
99
<script>
1010
// Use same django for material and django admin
1111
var django = django || {};

demo/templates/base.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!DOCTYPE html>{% load static %}
22
<html lang="en">
33
<head>
44
<meta charset="utf-8">
@@ -24,7 +24,7 @@
2424
{% block content %}{% endblock %}
2525
</div>
2626
{% block js %}
27-
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
27+
<script src="{% static 'material/js/jquery.js' %}"></script>
2828
{% include 'material/includes/material_js.html' %}
2929
{% block extrajs %}{% endblock %}
3030
{% endblock %}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{% load material_form material_form_internal i18n %}
2+
{% part bound_field.field %}<div class="row">
3+
<div{% attrs bound_field 'group' %}
4+
id="id_{{ bound_field.html_name }}_container"
5+
class="input-field file-field col s12{% if field.required %} required{% endif %}{% if bound_field.errors %} has-error{% endif %}"
6+
{% endattrs %}>
7+
<div class="btn">
8+
{% part field prefix %}<span>{% trans 'File' %}</span>{% endpart %}
9+
<input type="file" name="{{ bound_field.html_name }}"/>
10+
</div>
11+
{% part field suffix %}{% endpart %}{% part field control %}<div class="file-path-wrapper">
12+
<input{% attrs bound_field 'widget' default field.widget.attrs %}
13+
id="id_{{ bound_field.html_name }}"
14+
type="text"
15+
class="file-path"
16+
placeholder="{{ bound_field.label }}"
17+
{% if bound_field.value|is_initial_file %}value="{{ bound_field.value }}"{% endif %}
18+
{% endattrs %}>
19+
{% if bound_field.value|is_initial_file %}
20+
<a class="input-field-action" href="{{MEDIA_URL}}{{ bound_field.value.url }}" target="blank" title="{{ bound_field.value.name }}">
21+
<i class="material-icons">file_download</i>
22+
</a>
23+
{% endif %}
24+
</div>{% endpart %}
25+
{% part field help_text %}
26+
{% if field.help_text %}
27+
<div class="help-block">{{ bound_field.help_text|safe }}</div>
28+
{% endif %}
29+
{% endpart %}{% part field errors %}
30+
{% if bound_field.errors %}
31+
{% include 'material/field_errors.html' %}
32+
{% endif %}{% endpart %}{{ hidden_initial }}
33+
</div>
34+
</div>{% endpart %}

material/static/material/css/materialize.admin.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/static/material/css/materialize.forms.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ form .error {
3838
.input-field input[type=number] {
3939
-moz-appearance: textfield; }
4040

41+
.input-field .input-field-action {
42+
position: absolute;
43+
top: 0;
44+
right: 0;
45+
color: #555;
46+
padding: 0 0.75rem;
47+
line-height: 3rem;
48+
background: white; }
49+
.input-field .input-field-action i.material-icons {
50+
vertical-align: middle; }
51+
4152
.input-field ::-webkit-inner-spin-button {
4253
-webkit-appearance: none; }
4354

material/static/material/css/materialize.frontend.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/static/material/sass/materialize.forms.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,20 @@ form .error {
5050
-moz-appearance: textfield;
5151
}
5252

53+
.input-field-action {
54+
position: absolute;
55+
top: 0;
56+
right: 0;
57+
color: #555;
58+
padding: 0 0.75rem;
59+
line-height: 3rem;
60+
background: white;
61+
62+
i.material-icons {
63+
vertical-align: middle;
64+
}
65+
}
66+
5367
::-webkit-inner-spin-button {
5468
-webkit-appearance: none;
5569
}

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ universal = 1
44
[pep8]
55
max-line-length = 119
66

7+
[flake8]
8+
max-line-length = 119
9+
710
[pep257]
811
add-ignore = D100,D104,D105,D203
912
match = (?!\d{4}_)(?!test_).*\.py

0 commit comments

Comments
 (0)