Commit 89d98f7b329ec3962054b75d5e6dc18291886f2b

Authored by ailsoncgt
1 parent 1285c4d9

Template update file #135

Showing 1 changed file with 120 additions and 0 deletions   Show diff stats
files/templates/files/update_file.html 0 → 100644
... ... @@ -0,0 +1,120 @@
  1 +{% load static widget_tweaks i18n %}
  2 +
  3 +<!-- MODAL CREATE FILE -->
  4 +<link rel="stylesheet" type="text/css" href="{% static 'css/file.css' %}">
  5 +
  6 +<div class="erro-update">
  7 + <div class="modal fade" id="fileUpdateModal" tabindex="-1" role="dialog" aria-labelledby="updateFileLabel" style="z-index: 10">
  8 + <div class="modal-dialog" role="document">
  9 + <div class="modal-content">
  10 + <div class="modal-header">
  11 + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
  12 + <h4 class="modal-title" id="updateFileLabel">{% trans 'Edit File' %}</h4>
  13 + </div>
  14 + <div class="modal-body">
  15 + <!-- Card -->
  16 + <form class="form-horizontal" method="post" id="form-update-file" enctype="multipart/form-data">
  17 + {% csrf_token %}
  18 + {% if messages %}
  19 + {% for message in messages %}
  20 + <div class="alert alert-{{ message.tags }} alert-dismissible" role="alert">
  21 + <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  22 + <span aria-hidden="true">&times;</span>
  23 + </button>
  24 + <p>{{ message }}</p>
  25 + </div>
  26 + {% endfor %}
  27 + {% endif %}
  28 + <fieldset>
  29 + {% for field in form %}
  30 + <div class="form-group is-empy{% if form.has_error %} has-error {% endif %} is-fileinput">
  31 + <div class="col-md-12">
  32 + {% if field.field.required %}
  33 + <label for="{{ field.auto_id }}" class="control-label">{{ field.label }}<span>*</span></label>
  34 + {% else %}
  35 + <label for="{{ field.auto_id }}" class=" control-label">{{ field.label }}</label>
  36 + {% endif %}
  37 + {% if field.auto_id == 'id_file_url' %}
  38 + <input class="form-control input-sm" id="id_file_url" name="file_url" type="file">
  39 + <div class="input-group">
  40 + <input type="text" readonly="" class="form-control" placeholder="{% trans 'Choose your file...' %}">
  41 + <span class="input-group-btn input-group-sm">
  42 + <button type="button" class="btn btn-fab btn-fab-mini">
  43 + <i class="material-icons">attach_file</i>
  44 + </button>
  45 + </span>
  46 + </div>
  47 + <div class="crearfix">
  48 + <a href="{{ file.file_url.url }}" target="_blank">{% trans "See current file" %}</a>
  49 + </div>
  50 + {% else %}
  51 + {% render_field field class='form-control input-sm' %}
  52 + <span id="helpBlock" class="help-block">{{ field.help_text }}</span>
  53 + {% endif %}
  54 + </div>
  55 +
  56 + {% if field.errors %}
  57 + <div class="alert alert-danger alert-dismissible clearfix" role="alert">
  58 + <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  59 + <span aria-hidden="true">&times;</span>
  60 + </button>
  61 + <ul>
  62 + {% for error in field.errors %}
  63 + <li>{{ error }}</li>
  64 + {% endfor %}
  65 + </ul>
  66 + </div>
  67 + {% endif %}
  68 + </div>
  69 + {% endfor %}
  70 +
  71 + <div class="form-group">
  72 + <div class="col-md-12 text-center">
  73 + <p><b>The file size shouldn't exceed 10MB</b></p>
  74 + </div>
  75 + </div>
  76 +
  77 + <div class="form-group">
  78 + <div class="col-md-12">
  79 + <button type="button" class="btn btn-danger btn-raised" data-dismiss="modal">{% trans "Close" %}</button>
  80 + <button class="btn btn-raised btn-primary" type="submit">Submit</button>
  81 + </div>
  82 + </div>
  83 + </fieldset>
  84 + </form>
  85 + <!-- .end Card -->
  86 + </div>
  87 + </div>
  88 + </div>
  89 + </div>
  90 +</div>
  91 +
  92 +{% block script_file %}
  93 +
  94 + {# // <script src="{% static 'js/file.js' %}"></script> #}
  95 + <script type="text/javascript">
  96 + $("#form-update-file").submit(function(event) {
  97 + var data = new FormData($('#form-update-file').get(0));
  98 + $.ajax({
  99 + url: "{% url 'course:file:update_file' file.slug %}",
  100 + type: $("#form-update-file").attr('method'),
  101 + data: data,
  102 + cache: false,
  103 + processData: false,
  104 + contentType: false,
  105 + success: function(data) {
  106 + $('#fileUpdateModal').modal('hide');
  107 + alert(data);
  108 + // $('#list-topic-files').append(data);
  109 + },
  110 + error: function(data){
  111 + $('.erro-update').html(data.responseText);
  112 + $('.modal-backdrop').remove();
  113 + $('#fileUpdateModal').modal();
  114 + }
  115 + });
  116 + event.preventDefault();
  117 + });
  118 + </script>
  119 +{% endblock script_file %}
  120 +<!-- EndModal -->
0 121 \ No newline at end of file
... ...