# Path: competencies/models.py
# class SubjectArea(CoreElement):
#     subject_area = models.CharField(max_length=500)
#     organization = models.ForeignKey(Organization)
# 
#     def __str__(self):
#         return self.subject_area
# 
#     class Meta:
#         order_with_respect_to = 'organization'
# 
#     def is_parent_public(self):
#         return True
# 
#     def get_parent(self):
#         return self.organization
# 
#     def get_organization(self):
#         return self.organization


from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.rl_config import defaultPageSize
from reportlab.lib.units import inch
from competencies.models import SubjectArea
import os

os.environ['DJANGO_SETTINGS_MODULE'] = 'opencompetencies.settings'



class PDFTest():
    def __init__(self):
        self.PAGE_HEIGHT = defaultPageSize[1]
        self.PAGE_WIDTH = defaultPageSize[0]
        self.styles = getSampleStyleSheet()
        self.Title = ''
        self.subtitle = ''
        self.pageinfo = "platypus example"

    def myFirstPage(self, canvas, doc):
        canvas.saveState()
        canvas.setFont('Times-Bold',16)
        canvas.drawCentredString(inch, self.PAGE_HEIGHT-108, self.Title)
        canvas.drawString(inch, self.PAGE_HEIGHT-216, self.subtitle)
        canvas.setFont('Times-Roman',9)
        canvas.drawString(inch, 0.75 * inch,"First Page / %s" % self.pageinfo)
        canvas.restoreState()

    def myLaterPages(self, canvas, doc):
        canvas.saveState()
        canvas.setFont('Times-Roman', 9)
        canvas.drawString(inch, 0.75 * inch,"Page %d %s" % (doc.page, self.pageinfo))
        canvas.restoreState()

    def go(self, sa_id):

# Path: competencies/models.py
# class SubjectArea(CoreElement):
#     subject_area = models.CharField(max_length=500)
#     organization = models.ForeignKey(Organization)
# 
#     def __str__(self):
#         return self.subject_area
# 
#     class Meta:
#         order_with_respect_to = 'organization'
# 
#     def is_parent_public(self):
#         return True
# 
#     def get_parent(self):
#         return self.organization
# 
#     def get_organization(self):
#         return self.organization


# Path: pdf_test.py
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.rl_config import defaultPageSize
from reportlab.lib.units import inch
from competencies.models import SubjectArea
import os


os.environ['DJANGO_SETTINGS_MODULE'] = 'opencompetencies.settings'



class PDFTest():
    def __init__(self):
        self.PAGE_HEIGHT = defaultPageSize[1]
        self.PAGE_WIDTH = defaultPageSize[0]
        self.styles = getSampleStyleSheet()
        self.Title = ''
        self.subtitle = ''
        self.pageinfo = "platypus example"

    def myFirstPage(self, canvas, doc):
        canvas.saveState()
        canvas.setFont('Times-Bold',16)
        canvas.drawCentredString(inch, self.PAGE_HEIGHT-108, self.Title)
        canvas.drawString(inch, self.PAGE_HEIGHT-216, self.subtitle)
        canvas.setFont('Times-Roman',9)
        canvas.drawString(inch, 0.75 * inch,"First Page / %s" % self.pageinfo)
        canvas.restoreState()

    def myLaterPages(self, canvas, doc):
        canvas.saveState()
        canvas.setFont('Times-Roman', 9)
        canvas.drawString(inch, 0.75 * inch,"Page %d %s" % (doc.page, self.pageinfo))
        canvas.restoreState()

    def go(self, sa_id):

        sa = SubjectArea.objects.get(id=sa_id)