Ejemplo n.º 1
0
    def __init__(self,
                 dimensions,
                 applicant_roster,
                 font_family_id,
                 after_approve=None):
        super(ApplicantList, self).__init__(dimensions)

        _, _, width, height = self.getPosSize()

        self.applicant_roster = applicant_roster
        self.family_id = font_family_id
        self.after_approve = after_approve

        self.border = DashedRectangle((0, 0, width, height))
        self.enable_registry_button = CenteredButton(width,
                                                     height,
                                                     190,
                                                     24,
                                                     "Create Application Form",
                                                     callback=self.enable)

        self.label = TextBox((0, 0, -0, 22), "Applicants", sizeStyle="small")
        self.list = List((0, 23, 0, -34), [], columnDescriptions=self.columns)
        self.approve_applicant_button = Button((0, -24, 90, 24),
                                               "Approve",
                                               callback=self.approve_applicant)
        self.open_registration_page_button = Button(
            (-150, -20, 150, 17),
            "Open Application Form",
            callback=self.open_registration_page,
            sizeStyle="small")

        self.enabled = self.applicant_roster is not None
    def __init__(self, dimensions, font, applicants, recipients, after_approve=None):
        super(ApplicantList, self).__init__(dimensions)

        _, _, width, height = self.getPosSize()

        self.recipients = recipients
        self.applicants = applicants
        self.font = font
        self.after_approve = after_approve

        self.border = DashedRectangle((0, 0, width, height))
        self.activate_registry_button = CenteredButton(width, height, 190, 24,
                                                       "Activate Registration Page",
                                                       callback=self.activate)

        self.label = TextBox((0, 0, -0, 22), "Applicants")
        self.list = List((0, 23, 0, -34), applicants)
        self.approve_applicant_button = Button((0, -24, 90, 24),
                                               "Approve",
                                               callback=self.approve_applicant)
        self.open_registration_page_button = Button((-150, -20, 150, 17),
                                                    "Open Registration Page",
                                                    callback=self.open_registration_page,
                                                    sizeStyle="small")

        self.activated = font.lib.has_key('pm.ghostlines.ghostlines.registry_token')
Ejemplo n.º 3
0
    def __init__(self,
                 dimensions,
                 font,
                 applicants,
                 recipients,
                 after_approve=None):
        super(ApplicantList, self).__init__(dimensions)

        _, _, width, height = self.getPosSize()

        self.recipients = recipients
        self.applicants = applicants
        self.font = font
        self.after_approve = after_approve

        self.border = DashedRectangle((0, 0, width, height))
        self.activate_registry_button = CenteredButton(
            width,
            height,
            190,
            24,
            "Create Application Form",
            callback=self.activate)

        self.label = TextBox((0, 0, -0, 22), "Applicants")
        self.list = List((0, 23, 0, -34), applicants)
        self.approve_applicant_button = Button((0, -24, 90, 24),
                                               "Approve",
                                               callback=self.approve_applicant)
        self.open_registration_page_button = Button(
            (-150, -20, 150, 17),
            "Open Application Form",
            callback=self.open_registration_page,
            sizeStyle="small")

        self.activated = font.lib.has_key(
            'pm.ghostlines.ghostlines.registry_token')
class ApplicantList(Group):

    def __init__(self, dimensions, font, applicants, recipients, after_approve=None):
        super(ApplicantList, self).__init__(dimensions)

        _, _, width, height = self.getPosSize()

        self.recipients = recipients
        self.applicants = applicants
        self.font = font
        self.after_approve = after_approve

        self.border = DashedRectangle((0, 0, width, height))
        self.activate_registry_button = CenteredButton(width, height, 190, 24,
                                                       "Activate Registration Page",
                                                       callback=self.activate)

        self.label = TextBox((0, 0, -0, 22), "Applicants")
        self.list = List((0, 23, 0, -34), applicants)
        self.approve_applicant_button = Button((0, -24, 90, 24),
                                               "Approve",
                                               callback=self.approve_applicant)
        self.open_registration_page_button = Button((-150, -20, 150, 17),
                                                    "Open Registration Page",
                                                    callback=self.open_registration_page,
                                                    sizeStyle="small")

        self.activated = font.lib.has_key('pm.ghostlines.ghostlines.registry_token')

    def open_registration_page(self, *args):
        response = Ghostlines('v0.1').registry(self.font.lib['pm.ghostlines.ghostlines.registry_token'])
        registry = response.json()
        webbrowser.open(registry['url'])

    def approve_applicant(self, *args):
        selected_applicants = [self.list[i] for i in self.list.getSelection()]

        for applicant in selected_applicants:
            Ghostlines('v0.1').approve(self.font.lib['pm.ghostlines.ghostlines.registry_token'], applicant)
            self.after_approve(applicant)

        self.fetch()

    def activate(self, *args):
        response = Ghostlines('v0.1').enable_applicants({
            'font_name': self.font.info.familyName,
            'designer': self.font.info.designer
        })

        registry = response.json()

        self.font.lib['pm.ghostlines.ghostlines.registry_token'] = registry['token']
        self.activated = True

    def fetch(self):
        if self.font.lib.has_key('pm.ghostlines.ghostlines.registry_token'):
            response = Ghostlines('v0.1').registry(self.font.lib['pm.ghostlines.ghostlines.registry_token'])
            registry = response.json()
            applicant_emails = [r['email_address'] for r in registry['applicants'] if not r['approved_at']]

            self.list.set(applicant_emails)

    @property
    def activated(self):
        return self._activated

    @activated.setter
    def activated(self, value):
        self._activated = value

        self.label.show(value)
        self.list.show(value)
        self.approve_applicant_button.show(value)
        self.border.show(not value)
        self.activate_registry_button.show(not value)
        self.open_registration_page_button.show(value)

        return self.activated
Ejemplo n.º 5
0
class ApplicantList(Group):

    columns = [{
        "title": "Name",
        "key": "name",
        "editable": False
    }, {
        "title": "Email Address",
        "key": "email_address",
        "editable": False
    }]

    def __init__(self,
                 dimensions,
                 applicant_roster,
                 font_family_id,
                 after_approve=None):
        super(ApplicantList, self).__init__(dimensions)

        _, _, width, height = self.getPosSize()

        self.applicant_roster = applicant_roster
        self.family_id = font_family_id
        self.after_approve = after_approve

        self.border = DashedRectangle((0, 0, width, height))
        self.enable_registry_button = CenteredButton(width,
                                                     height,
                                                     190,
                                                     24,
                                                     "Create Application Form",
                                                     callback=self.enable)

        self.label = TextBox((0, 0, -0, 22), "Applicants", sizeStyle="small")
        self.list = List((0, 23, 0, -34), [], columnDescriptions=self.columns)
        self.approve_applicant_button = Button((0, -24, 90, 24),
                                               "Approve",
                                               callback=self.approve_applicant)
        self.open_registration_page_button = Button(
            (-150, -20, 150, 17),
            "Open Application Form",
            callback=self.open_registration_page,
            sizeStyle="small")

        self.enabled = self.applicant_roster is not None

    def open_registration_page(self, *args):
        webbrowser.open(self.applicant_roster['url'])

    def approve_applicant(self, *args):
        selected_applicants = [self.list[i] for i in self.list.getSelection()]

        for applicant in selected_applicants:
            token = AppStorage("accessToken").retrieve()
            Ghostlines('v1', token=token).approve_applicant(applicant["id"])

        self.after_approve()
        self.fetch()

    def enable(self, *args):
        token = AppStorage("accessToken").retrieve()
        response = Ghostlines('v1',
                              token=token).enable_applicants_v1(self.family_id)
        json = response.json()

        if response.status_code == 201:
            self.applicant_roster = json
            self.enabled = True
        else:
            ErrorMessage("Could not enable applicants", json["errors"]).open()

    def fetch(self):
        if self.enabled:
            token = AppStorage("accessToken").retrieve()
            response = Ghostlines('v1',
                                  token=token).applicant_roster(self.family_id)
            self.applicant_roster = response.json()
            self.set(self.applicant_roster["applicants"])

    def set(self, applicants):
        unapproved = [a for a in applicants if a["approved_at"] is None]
        self.list.set(unapproved)

    @property
    def enabled(self):
        return self._enabled

    @enabled.setter
    def enabled(self, value):
        self._enabled = value

        self.label.show(value)
        self.list.show(value)
        self.approve_applicant_button.show(value)
        self.border.show(not value)
        self.enable_registry_button.show(not value)
        self.open_registration_page_button.show(value)

        return self.enabled
Ejemplo n.º 6
0
class ApplicantList(Group):
    def __init__(self,
                 dimensions,
                 font,
                 applicants,
                 recipients,
                 after_approve=None):
        super(ApplicantList, self).__init__(dimensions)

        _, _, width, height = self.getPosSize()

        self.recipients = recipients
        self.applicants = applicants
        self.font = font
        self.after_approve = after_approve

        self.border = DashedRectangle((0, 0, width, height))
        self.activate_registry_button = CenteredButton(
            width,
            height,
            190,
            24,
            "Create Application Form",
            callback=self.activate)

        self.label = TextBox((0, 0, -0, 22), "Applicants")
        self.list = List((0, 23, 0, -34), applicants)
        self.approve_applicant_button = Button((0, -24, 90, 24),
                                               "Approve",
                                               callback=self.approve_applicant)
        self.open_registration_page_button = Button(
            (-150, -20, 150, 17),
            "Open Application Form",
            callback=self.open_registration_page,
            sizeStyle="small")

        self.activated = font.lib.has_key(
            'pm.ghostlines.ghostlines.registry_token')

    def open_registration_page(self, *args):
        response = Ghostlines('v0.1').registry(
            self.font.lib['pm.ghostlines.ghostlines.registry_token'])
        registry = response.json()
        webbrowser.open(registry['url'])

    def approve_applicant(self, *args):
        selected_applicants = [self.list[i] for i in self.list.getSelection()]

        for applicant in selected_applicants:
            Ghostlines('v0.1').approve(
                self.font.lib['pm.ghostlines.ghostlines.registry_token'],
                applicant)
            self.after_approve(applicant)

        self.fetch()

    def activate(self, *args):
        response = Ghostlines('v0.1').enable_applicants({
            'font_name':
            self.font.info.familyName,
            'designer':
            self.font.info.openTypeNameDesigner
        })

        registry = response.json()

        self.font.lib['pm.ghostlines.ghostlines.registry_token'] = registry[
            'token']
        self.activated = True

    def fetch(self):
        if self.font.lib.has_key('pm.ghostlines.ghostlines.registry_token'):
            response = Ghostlines('v0.1').registry(
                self.font.lib['pm.ghostlines.ghostlines.registry_token'])
            registry = response.json()
            applicant_emails = [
                r['email_address'] for r in registry['applicants']
                if not r['approved_at']
            ]

            self.list.set(applicant_emails)

    @property
    def activated(self):
        return self._activated

    @activated.setter
    def activated(self, value):
        self._activated = value

        self.label.show(value)
        self.list.show(value)
        self.approve_applicant_button.show(value)
        self.border.show(not value)
        self.activate_registry_button.show(not value)
        self.open_registration_page_button.show(value)

        return self.activated