Esempio n. 1
0
    def createfirm(self, sess, comment, investor, firm_name):
        if investor.firm != 0:
            existing_firm = sess.query(Firm).\
                filter(Firm.id == investor.firm).\
                first()
            return comment.reply_wrap(
                message.modify_createfirm_exists_failure(existing_firm.name))

        if investor.balance < 100000:
            return comment.reply_wrap(message.createfirm_cost_failure_org)

        firm_name = firm_name.strip()

        if (len(firm_name) < 4) or (len(firm_name) > 32):
            return comment.reply_wrap(message.createfirm_format_failure_org)

        if self.firm_name_regex.search(firm_name):
            return comment.reply_wrap(message.createfirm_format_failure_org)

        existing_firm = sess.query(Firm).\
            filter(Firm.name == firm_name).\
            first()

        if existing_firm:
            return comment.reply_wrap(message.createfirm_nametaken_failure_org)

        sess.add(Firm(name=firm_name))
        firm = sess.query(Firm).\
            filter(Firm.name == firm_name).\
            first()

        investor.balance -= 100000
        investor.firm = firm.id
        investor.firm_role = "ceo"
        firm.ceo = investor.name
        firm.size += 1

        # Setting up the flair in subreddits
        # Hardcoded CEO string because createfirm makes a user CEO
        if not config.TEST:
            for subreddit in config.SUBREDDITS:
                REDDIT.subreddit(subreddit).flair.set(investor.name,
                                                      f"{firm_name} | CEO")
        return comment.reply_wrap(message.createfirm_org)
Esempio n. 2
0
#!/usr/bin/python

from models import Firm
from config import urls

print Firm

urlDataAsObjects = []

for newFirm in urls.dataUrlsOfFirms:
    urlDataAsObjects.append(Firm.Builder(newFirm))