Commit da75287a authored by Gladys Forte's avatar Gladys Forte

update delete master attachment

parent 711ecbf5
...@@ -3,7 +3,7 @@ __pycache__/ ...@@ -3,7 +3,7 @@ __pycache__/
*.py[cod] *.py[cod]
*$py.class *$py.class
env.ini env.ini
# media/ media/
docker-compose.yml docker-compose.yml
Dockerfile Dockerfile
......
# from rest_framework.views import APIView
# from rest_framework import viewsets, status
# from rest_framework.response import Response
# from reportlab.lib.enums import TA_JUSTIFY, TA_RIGHT, TA_LEFT, TA_CENTER
# from reportlab.lib.pagesizes import letter
# from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
# import reportlab
# from reportlab.lib.pagesizes import A4
# from django.http import FileResponse
# from django.shortcuts import HttpResponse
# import io
# import subprocess
# import datetime
# from reportlab.lib.pagesizes import letter
# from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image
# from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
# from reportlab.lib.units import inch
# from reportlab.pdfbase.ttfonts import TTFont
# from reportlab.pdfbase import pdfmetrics
# from reportlab.lib.colors import red, black, navy, white, green
# from reportlab.platypus import Paragraph, SimpleDocTemplate, XBox, Indenter, XPreformatted
# class PDF2(APIView):
# def get(self, request, format=None):
# doc = SimpleDocTemplate("instruction.pdf",
# pagesize=A,
# rightMargin=72,
# leftMargin=72,
# topMargin=72,
# bottomMargin=18)
# Story = []
# styles=getSampleStyleSheet()
# styles.add(ParagraphStyle(name='Justify', alignment=TA_JUSTIFY, fontName='Helvetica', fontSize=12))
# styles.add(ParagraphStyle('reminder',
# fontName='Helvetica',
# fontSize=13,
# leading=28,
# textColor=red))
# items = [
# "1. To be able to add multiple users in the system, you must first <u>Download the</u>",
# "<font color=white>....</font><u>template.</u>",
# "2. This file includes a sample entry as your basis for adding users in the file",
# "3. This file also includes all the Departments currently in the system, as your basis",
# "<font color=white>....</font>in indicating privileges for each user. ",
# "4. Make sure to indicate the Department Code, Department Name and Company",
# "<font color=white>....</font>Name (Department details) that you would want the user to access.",
# "5. If the user should have access to multiple Departments, just repeat all the details",
# "<font color=white>....</font>of the user and change the Department details and privileges assignment in each",
# "<font color=white>....</font>line for the user.",
# "6. Take note of the following Application Abbreviations, to be indicated in the",
# "<font color=white>...</font>Application and Default Application (default_app) column of the CSV file: ",
# "<font color=white>...</font>6.1.<b>RMS</b> is Resource Management System",
# "<font color=white>...</font>6.2.<b>CMS</b> is Change Request Management System",
# "<font color=white>...</font>6.3.<b>AMS</b> is Asset Management System",
# "7. The template is in CSV format, after filling up the details, make sure that the file is",
# "<font color=white>....</font>still saved in CSV format before uploading in the system."
# ]
# ptext = '<font size=13>IMPORTANT REMINDERS</font>'
# Story.append(Paragraph(ptext, styles["reminder"]))
# Story.append(Spacer(1, 15))
# for item in items:
# ptext = '<font size=12>' + item + '</font>'
# Story.append(Paragraph(ptext, styles["Justify"]))
# Story.append(Spacer(1, 12))
# doc.build(Story)
# return Response(
# {"results": "attachments"},
# status=status.HTTP_200_OK
# )
\ No newline at end of file
...@@ -31,13 +31,3 @@ class BatchUploadSerializer(serializers.ModelSerializer): ...@@ -31,13 +31,3 @@ class BatchUploadSerializer(serializers.ModelSerializer):
) )
class UserInstructionSerializer(serializers.ModelSerializer):
class Meta:
model = MasterAttachment
fields = '__all__'
read_only_fields = (
'created', 'createdby', 'modified', 'modifiedby', 'code',
)
...@@ -202,7 +202,7 @@ class BatchUploadViewSet(viewsets.ModelViewSet): ...@@ -202,7 +202,7 @@ class BatchUploadViewSet(viewsets.ModelViewSet):
"7. The template is in CSV format, after filling up the details, make sure that the file ", "7. The template is in CSV format, after filling up the details, make sure that the file ",
"<font color=white>...</font>is still saved in CSV format before uploading in the system." "<font color=white>...</font>is still saved in CSV format before uploading in the system."
] ]
ptext = '<font size=13>IMPORTANT REMINDERS</font>' ptext = '<font size=13>IMPORTANT REMINDERS</font>'
instruction_data.append(Paragraph(ptext, styles["reminder"])) instruction_data.append(Paragraph(ptext, styles["reminder"]))
instruction_data.append(Spacer(1, 15)) instruction_data.append(Spacer(1, 15))
......
...@@ -527,22 +527,22 @@ class MasterAttachment(models.Model): ...@@ -527,22 +527,22 @@ class MasterAttachment(models.Model):
attch_ref = models.TextField() attch_ref = models.TextField()
# def delete(self,*args,**kwargs): def delete(self,*args,**kwargs):
# print(self.url.name) print(self.url.name)
# if os.path.isfile(self.url.path): if os.path.isfile(self.url.path):
# os.remove(self.url.path) os.remove(self.url.path)
# super(MasterAttachment, self).delete(*args,**kwargs) super(MasterAttachment, self).delete(*args,**kwargs)
class Meta: class Meta:
db_table = 'master_attachments' db_table = 'master_attachments'
def delete(self, *args, **kwargs): # def delete(self, *args, **kwargs):
# self.url.delete() # # self.url.delete()
# super().delete(*args, **kwargs) # # super().delete(*args, **kwargs)
os.remove(os.path.join(settings.MEDIA_ROOT, self.url.name)) # os.remove(os.path.join(settings.MEDIA_ROOT, self.url.name))
super(MasterAttachment, self).delete(*args, **kwargs) # super(MasterAttachment, self).delete(*args, **kwargs)
class BaseAttachment(models.Model): class BaseAttachment(models.Model):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment