Exemple #1
0
 def __init__(self, id, **kwargs):
     """Create a new proposal instance. This MUST have an ID
     to be valid; we do not create new proposals from nowhere
     for our purposes.
     """
     kwargs['id'] = int(id)
     kwargs['thunderdome_votes'] = None
     kwargs['decided'] = False
     self.__dict__.update({
         'api': API(),
         'data': kwargs,
     })
Exemple #2
0
class ThunderdomeGroupManager(object):
    """Class that understands how to retrieve and filter thunderdome groups,
    acquired from the PyCon website.
    """
    def __init__(self):
        self.api = API()

    def all(self):
        return self.filter()

    def filter(self, undecided=False):
        """Return a list of thunderdome groups, optionally filtering out
        groups that have already been decided.
        """
        kwargs = {}
        if undecided:
            kwargs['undecided'] = undecided

        response = self.api.get('thunderdome_groups', **kwargs)
        return [ThunderdomeGroup(**i) for i in response['data']]

    def get(self, code):
        """Return back a single proposal given the following code.
        We do not filter on anything other than code here.
        """
        try:
            response = self.api.get('thunderdome_groups/%s' % code)
        except NotFound:
            raise ThunderdomeGroup.DoesNotExist('No group with code %s.'
                                                % code)
        return ThunderdomeGroup(**response['data'])

    def next(self, undecided=True):
        """Return the next thunderdome group that should be decided."""

        try:
            return self.filter(undecided=True)[1]
        except KeyError:
            return None
Exemple #3
0
class ThunderdomeGroupManager(object):
    """Class that understands how to retrieve and filter thunderdome groups,
    acquired from the PyCon website.
    """
    def __init__(self):
        self.api = API()

    def all(self):
        return self.filter()

    def filter(self, undecided=False):
        """Return a list of thunderdome groups, optionally filtering out
        groups that have already been decided.
        """
        kwargs = {}
        if undecided:
            kwargs['undecided'] = undecided

        response = self.api.get('thunderdome_groups', **kwargs)
        return [ThunderdomeGroup(**i) for i in response['data']]

    def get(self, code):
        """Return back a single proposal given the following code.
        We do not filter on anything other than code here.
        """
        try:
            response = self.api.get('thunderdome_groups/%s' % code)
        except NotFound:
            raise ThunderdomeGroup.DoesNotExist('No group with code %s.' %
                                                code)
        return ThunderdomeGroup(**response['data'])

    def next(self, undecided=True):
        """Return the next thunderdome group that should be decided."""

        try:
            return self.filter(undecided=True)[1]
        except KeyError:
            return None
Exemple #4
0
    def __init__(self, code, talks=(), **kwargs):
        """Create a new thunderdome group instance. This MUST have a code
        to be valid; we do not create new groups or proposals from nowhere
        for our purposes.
        """
        # Iterate over the talks and make Proposal objects from each.
        talks_ = []
        for t in talks:
            talks_.append(Proposal(**t))
        kwargs['talks'] = talks_

        # Set the code.
        kwargs['code'] = code

        # Set an empty decision object.
        kwargs['decision'] = {}

        # Write the things to the object.
        self.__dict__.update({
            'api': API(),
            'data': kwargs,
        })
Exemple #5
0
class ProposalManager(object):
    """Class that understands how to retrieve and filter proposals,
    acquired from the PyCon website.
    """
    def __init__(self):
        self.api = API()

    def filter(self, **kwargs):
        """Return a list of proposals."""
        kwargs.setdefault('type', 'talk')
        response = self.api.get('proposals', **kwargs)
        return [Proposal(**i) for i in response['data']]

    def get(self, id):
        """Return back a single proposal given the following ID.
        We do not filter on anything other than ID here.
        """
        try:
            response = self.api.get('proposals/%d' % int(id))
        except NotFound:
            raise Proposal.DoesNotExist('No proposal with ID %d.' % int(id))
        return Proposal(**response['data'])

    def next(self, type=None, status=None, after=None):
        """Return the next talk that should be reviewed.

        Right now the API has some limitations, so this is super bonus janky.
        It basically gets all the talks and then iterates until it finds
        the right one.
        """
        # First, what kind of talk are we looking at?
        manager_method = 'all'
        if type:
            manager_method = type + 's'

        # Get the list of talks.
        proposals = getattr(self, manager_method)()

        # Iterate over the proposals we got back until we get
        # the one we want.
        for proposal in proposals:
            # If the status isn't what I expect, keep going.
            if proposal.status != status:
                continue

            # If the proposal ID is too low, keep going.
            if proposal.id <= after:
                continue

            # Return this talk!
            return proposal

        # Whups, we didn't find what we wanted; complain.
        raise Proposal.DoesNotExist('No more talks!')

    def all(self):
        return self.filter()

    def talks(self):
        return self.filter(type='talk')

    def tutorials(self):
        return self.filter(type='tutorial')

    def lightning_talks(self):
        return self.filter(type='lightning_talk')

    def posters(self):
        return self.filter(type='poster')
Exemple #6
0
 def __init__(self):
     self.api = API()
Exemple #7
0
class ProposalManager(object):
    """Class that understands how to retrieve and filter proposals,
    acquired from the PyCon website.
    """
    def __init__(self):
        self.api = API()

    def filter(self, **kwargs):
        """Return a list of proposals."""
        kwargs.setdefault('type', 'talk')
        response = self.api.get('proposals', **kwargs)
        return [Proposal(**i) for i in response['data']]

    def get(self, id):
        """Return back a single proposal given the following ID.
        We do not filter on anything other than ID here.
        """
        try:
            response = self.api.get('proposals/%d' % int(id))
        except NotFound:
            raise Proposal.DoesNotExist('No proposal with ID %d.' % int(id))
        return Proposal(**response['data'])

    def next(self, type=None, status=None, after=None):
        """Return the next talk that should be reviewed.

        Right now the API has some limitations, so this is super bonus janky.
        It basically gets all the talks and then iterates until it finds
        the right one.
        """
        # First, what kind of talk are we looking at?
        manager_method = 'all'
        if type:
            manager_method = type + 's'

        # Get the list of talks.
        proposals = getattr(self, manager_method)()

        # Iterate over the proposals we got back until we get
        # the one we want.
        for proposal in proposals:
            # If the status isn't what I expect, keep going.
            if proposal.status != status:
                continue

            # If the proposal ID is too low, keep going.
            if proposal.id <= after:
                continue

            # Return this talk!
            return proposal

        # Whups, we didn't find what we wanted; complain.
        raise Proposal.DoesNotExist('No more talks!')

    def all(self):
        return self.filter()

    def talks(self):
        return self.filter(type='talk')

    def tutorials(self):
        return self.filter(type='tutorial')

    def lightning_talks(self):
        return self.filter(type='lightning_talk')

    def posters(self):
        return self.filter(type='poster')
Exemple #8
0
 def __init__(self):
     self.api = API()