Commit 5f5f8e88ba063935a8b57eb20f493705e55b3f03

Authored by Zambom
1 parent 43aeeef6

Adjusting news image and adding it in presentation

amadeus/static/js/crop_news.js
1 $(function () { 1 $(function () {
2 /* Script para abrir o modal com a imagem selecionada */ 2 /* Script para abrir o modal com a imagem selecionada */
3 $("#id_image").change(function () { 3 $("#id_image").change(function () {
4 - var max_size = 2*1024*1024; 4 + var max_size = 5*1024*1024;
5 var submit_btn = $("#news-form").find("input[type='submit']"); 5 var submit_btn = $("#news-form").find("input[type='submit']");
6 var mimeTypes = $(this).data('mimetypes'); 6 var mimeTypes = $(this).data('mimetypes');
7 var errors = 0; 7 var errors = 0;
@@ -21,7 +21,7 @@ $(function () { @@ -21,7 +21,7 @@ $(function () {
21 $(".size").show(); 21 $(".size").show();
22 22
23 errors++; 23 errors++;
24 - } 24 + }
25 25
26 if (!mimeTypes.includes(this.files[0].type)) { 26 if (!mimeTypes.includes(this.files[0].type)) {
27 $(submit_btn).prop('disable', true); 27 $(submit_btn).prop('disable', true);
@@ -30,8 +30,8 @@ $(function () { @@ -30,8 +30,8 @@ $(function () {
30 $(".client-file-errors").show(); 30 $(".client-file-errors").show();
31 $(".format").show(); 31 $(".format").show();
32 32
33 - errors++;  
34 - } 33 + errors++;
  34 + }
35 35
36 if (errors == 0) { 36 if (errors == 0) {
37 var reader = new FileReader(); 37 var reader = new FileReader();
@@ -51,7 +51,7 @@ $(function () { @@ -51,7 +51,7 @@ $(function () {
51 $("#modalCrop").on("shown.bs.modal", function () { 51 $("#modalCrop").on("shown.bs.modal", function () {
52 $image.cropper({ 52 $image.cropper({
53 viewMode: 1 , 53 viewMode: 1 ,
54 - aspectRatio: 24/5, 54 + aspectRatio: 3/1,
55 minCropBoxWidth: 200, 55 minCropBoxWidth: 200,
56 minCropBoxHeight: 200, 56 minCropBoxHeight: 200,
57 dragMode: 'move', 57 dragMode: 'move',
@@ -31,7 +31,7 @@ class NewsForm(forms.ModelForm): @@ -31,7 +31,7 @@ class NewsForm(forms.ModelForm):
31 image = Image.open(self.instance.image) 31 image = Image.open(self.instance.image)
32 if not x is None: 32 if not x is None:
33 cropped_image = image.crop((x, y, w+x, h+y)) 33 cropped_image = image.crop((x, y, w+x, h+y))
34 - resized_image = cropped_image.resize((1200, 250), Image.ANTIALIAS) 34 + resized_image = cropped_image.resize((1200, 400), Image.ANTIALIAS)
35 35
36 folder_path = join(settings.MEDIA_ROOT, 'news') 36 folder_path = join(settings.MEDIA_ROOT, 'news')
37 #check if the folder already exists 37 #check if the folder already exists
news/templates/news/view.html
@@ -29,9 +29,16 @@ @@ -29,9 +29,16 @@
29 <div class="row-fluid panel panel-default" > 29 <div class="row-fluid panel panel-default" >
30 <div class="panel-body" id="printArea"> 30 <div class="panel-body" id="printArea">
31 <div class="col-md-12" style="display:inline-block"> 31 <div class="col-md-12" style="display:inline-block">
32 - <h2><b>{{new.title}}</b></h2> <button style="text-transform:none; text-decoration: underline;" type="button" class="pull-right btn btn-default btn-sm" id="printButton" name="button">{% trans "Print News" %} <i class="fa fa-print" aria-hidden="true"></i></button><br> 32 + <h2><b>{{new.title}}</b></h2>
  33 + </div>
  34 + <div class="col-md-12" style="margin-top: -30px;">
  35 + <button style="text-transform:none; text-decoration: underline;" type="button" class="pull-right btn btn-default btn-sm" id="printButton" name="button">{% trans "Print News" %}
  36 + <i class="fa fa-print" aria-hidden="true"></i></button><br>
33 <p>{{new.creator}}, em {{new.create_date}}</p> 37 <p>{{new.creator}}, em {{new.create_date}}</p>
34 </div> 38 </div>
  39 + <div class="col-md-12" style="margin-top: 20px; margin-bottom: 20px;">
  40 + <span><img src="{% if new.image %}{{ new.image.url }}{% endif %}" width="100%"></span>
  41 + </div>
35 <div class="col-md-12"> 42 <div class="col-md-12">
36 <br> 43 <br>
37 {% autoescape off %} 44 {% autoescape off %}