Beispiel #1
0
def monitorNewAccounts():
    #time when emails will be sent
    start = datetime.time(16, 59)
    end = datetime.time(17, 00)
    while (datetime.datetime.now().time() < start
           or datetime.datetime.now().time() > end):

        #takes input through keyboard on 20 second timer (so it doesnt get tied up when reports get emailed)
        stringer = timed_Input()

        #if there was an email
        if (stringer != None):
            #parses the input message
            message = stringer.split(",")

            #if the message is saying to create a new account with signal "0000"
            if (message[0] == "0000"):
                if (len(message) >= 10):
                    # creates new user with an email
                    new_account = Accounts(float(message[1]), float(
                        message[2]), float(message[3]), float(message[4]),
                                           float(message[5]),
                                           float(message[6]),
                                           float(message[7]),
                                           float(message[8]), message[9])
            # email not included
                else:
                    new_account = Accounts(float(message[1]), float(
                        message[2]), float(message[3]), float(message[4]),
                                           float(message[5]),
                                           float(message[6]),
                                           float(message[7]),
                                           float(message[8]))

                #creates new user id, if it already exists increments until finds number that doesnt exist
                new_id = random.randrange(1, 999)
                while (new_id in created_accounts):
                    new_id = new_id + 1

                #adds new account with new id to the existing accounts
                created_accounts[str(new_id)] = new_account

                #generate report
                reply = generate_report(str(new_id), created_accounts, True)

            #else the user already exists OR you need to create new account
            else:
                reply = generate_report(str(message[0]), created_accounts,
                                        False)

            #returns the report generated
            print(reply)
            print('\nEnter something.')

    #in time range to send reports so calls send reports and then loops back in
    sendReports()
Beispiel #2
0
    def __init__(self, dbPath, dbName):
        self.database = dbPath + dbName
        self.dataPath = dbPath
        self.visits = Visits()
        self.guests = Guests()
        self.reports = Reports(self)
        self.teams = Teams()
        self.accounts = Accounts()
        self.devices = Devices()
        self.unlocks = Unlocks()
        # needs path since it will open read only
        self.customReports = CustomReports(self.database)
        self.certifications = Certifications()
        self.members = Members()
        self.logEvents = LogEvents()

        if not os.path.exists(self.database):
            if not os.path.exists(dbPath):
                os.mkdir(dbPath)
            with self.dbConnect() as c:
                self.migrate(c, 0)
        else:
            with self.dbConnect() as c:
                data = c.execute('PRAGMA schema_version').fetchone()
                if data[0] != SCHEMA_VERSION:
                    self.migrate(c, data[0])
Beispiel #3
0
    def get(self):
        Guser = users.get_current_user()
        
        if Guser:
            URL = self.request.url

            vstrURLlist = URL.split("/")
            vstrListID = vstrURLlist[len(vstrURLlist) - 1]

            findRequest = Accounts.query(Accounts.strUserID == Guser.user_id())
            thisAccountsList = findRequest.fetch()

            if len(thisAccountsList) > 0:
                thisAccounts = thisAccountsList[0]
            else:
                thisAccounts = Accounts()

            findRequest = MailingList.query(MailingList.strListID == vstrListID,MailingList.strOrganizationID == thisAccounts.strOrganizationID)
            thisMailingList = findRequest.fetch()

            if len(thisMailingList) > 0:
                thisNewsLetter = thisMailingList[0]
            else:
                thisNewsLetter = MailingList()

            template = template_env.get_template('templates/newsletter/thisNewsletter.html')
            context = {'thisNewsLetter':thisNewsLetter}
            self.response.write(template.render(context))
 def test_save_multiple_accounts(self):
     '''
     a test that checks whether both values appended to the array are actually present\ and returns the acount itself
     '''
     self.new_account.save_account()
     test_account = Accounts('abcd', 'efgh', 'ijkl', 'mnop')
     test_account.save_account()
     self.assertEqual(len(Accounts.user_accounts), 2)
 def test_account_exists(self):
     '''
     unlike the previous test this test returns a true/false soort of answer depending on whether the account exists or not
     '''
     self.new_account.save_account()
     test_account = Accounts('abcd', 'efgh', 'ijkl', 'mnop')
     test_account.save_account()
     account_exists = Accounts.account_exists('ijkl')
     self.assertTrue(account_exists)
 def test_find_account_by_username(self):
     '''
     test to check whether the function used to find accounts really works
     '''
     self.new_account.save_account()
     test_account = Accounts('abcd', 'efgh', 'ijkl', 'mnop')
     test_account.save_account()
     found_account = Accounts.find_by_user_name('ijkl')
     self.assertEqual(found_account.user_name, test_account.user_name)
 def test_del_account(self):
     '''
     test that check the delete function
     '''
     self.new_account.save_account()
     test_account = Accounts('abcd', 'efgh', 'ijkl', 'mnop')
     test_account.save_account()
     self.new_account.delete_account()
     self.assertEqual(len(Accounts.user_accounts), 1)
Beispiel #8
0
def processAccounts():
    accountsList = []
    accountsFile = open('static/file/acc', 'r')
    for alist in accountsFile:
        list = alist.split(',')
        s = Accounts(list[0], list[1], int(list[2]))

        accountsList.append(s)

    return accountsList
Beispiel #9
0
    def post(self):

        vstrChoice = self.request.get('vstrChoice')

        if vstrChoice == "0":
            #'&vstrUserID=' + struid + '&vstrEmail=' + email + '&vstrAccessToken=' + accessToken
            vstrUserID = self.request.get("vstrUserID")
            vstrEmail = self.request.get("vstrEmail")
            vstrAccessToken = self.request.get("vstrAccessToken")


            vstrListName = self.request.get('vstrListName')
            vstrListDescription = self.request.get('vstrListDescription')
            vstrStartSendingDate = self.request.get('vstrStartSendingDate')
            DateList = vstrStartSendingDate.split("-")
            strYear = int(DateList[0])
            strMonth = int(DateList[1])
            strDay = int(DateList[2])

            vstrDate = datetime.date(year=strYear,month=strMonth,day=strDay)


            vstrStartSendingTime = self.request.get('vstrStartSendingTime')
            TimeList = vstrStartSendingTime.split(":")
            strHour = int(TimeList[0])
            strMinute = int(TimeList[1])
            vstrTime = datetime.time(hour=strHour,minute=strMinute,second=0)



            findRequest = Accounts.query(Accounts.strUserID == vstrUserID)
            thisAccountsList = findRequest.fetch()

            if len(thisAccountsList) > 0:
                thisAccounts = thisAccountsList[0]
            else:
                thisAccounts = Accounts()

            findRequest = MailingList.query(MailingList.strOrganizationID == thisAccounts.strOrganizationID,MailingList.strListName == vstrListName,MailingList.strListDescription == vstrListDescription)
            thisMailingList = findRequest.fetch()

            if len(thisMailingList) > 0:
                thisMailing = thisMailingList[0]
            else:
                thisMailing = MailingList()
                thisMailing.writeListID(strinput=thisMailing.CreateListID())

            thisMailing.writeOrganizationID(strinput=thisAccounts.strOrganizationID)
            thisMailing.writeListName(strinput=vstrListName)
            thisMailing.writeListDescription(strinput=vstrListDescription)
            thisMailing.writeStartSendingDate(strinput=vstrDate)
            thisMailing.writeStartSendingTime(strinput=vstrTime)
            thisMailing.put()
            self.response.write("Mailing List successfully update")
Beispiel #10
0
def main_menu(session, base_url):
    """
    Provides the different options for the sample application: Market Quotes, Account List

    :param session: authenticated session
    """

    market = Market(session, base_url)
    accounts = Accounts(session, base_url)
    order = Order(session, {}, base_url)

    # ret = market.quoteCommon("vsat")
    # print ("MARKET FOR VST", ret)

    accountsObj = accounts.printPorfolio(PERCENT)
    accountsList = accountsObj['acct']
    accountsPort = accountsObj['port']
    ordersAcct = {}
    for account in accountsList:
        ordersAcct[account['accountId']] = order.viewOpenOrder(account, False)
    checkAccountOrder(accountsPort, ordersAcct)
    menu_items = {"1": "Market Quotes",
                  "2": "Account List",
                  "3": "Place File order", 
                  "4": "Cancel all open orders",
                  "5": "Cancel ALL orders and redo on current price",
                  "6": "redo diff orders",
                  "7": "Exit"}

    while True:
        print("")
        options = menu_items.keys()
        for entry in options:
            print(entry + ")\t" + menu_items[entry])
        selection = input("Please select an option: ")
        if selection == "1":
            market.quotes()
        elif selection == "2":
            accounts.account_list()
        elif selection == "3":
            order.readCSV(False)
        elif selection == "4":
            for account in accountsList:
                order.viewOpenOrder(account, True)
        elif selection == "5":
            for account in accountsList:
                order.viewOpenOrder(account, True)
            order.readCSV(True)
        elif selection == "6":
            order.dodiff()
        elif selection == "7":
            break
        else:
            print("Unknown Option Selected!")
    def post(self):
        Guser = users.get_current_user()
        if Guser:
            vstrPaymentMethod = self.request.get('vstrPaymentMethod').value

            if vstrPaymentMethod == "Cash":
                findRequest = Accounts.query(
                    Accounts.strReference == Guser.user_id())
                thisAccountsList = findRequest.fetch()

                if len(thisAccountsList) > 0:
                    thisAccount = thisAccountsList[0]
                else:
                    thisAccount = Accounts()
Beispiel #12
0
    def post(self):

        from mysms import SMSAccount
        from accounts import Accounts, Organization

        #'&vstrUserID=' + struid + '&vstrEmail=' + email + '&vstrAccessToken=' + accessToken;
        vstrUserID = self.request.get('vstrUserID')
        vstrEmail = self.request.get('vstrEmail')
        vstrAccessToken = self.request.get('vstrAccessToken')

        findRequest = Accounts.query(Accounts.strUserID == vstrUserID)
        thisAccountList = findRequest.fetch()

        if len(thisAccountList) > 0:
            thisAccount = thisAccountList[0]
        else:
            findRequest = Accounts.query(Accounts.strEmail == vstrEmail)
            thisAccountList = findRequest.fetch()

            if len(thisAccountList) > 0:
                thisAccount = thisAccountList[0]
            else:
                thisAccount = Accounts()

        findRequest = SMSAccount.query(
            SMSAccount.strOrganizationID == thisAccount.strOrganizationID)
        thisSMSAccountList = findRequest.fetch()

        if len(thisSMSAccountList) > 0:
            thisSMSAccount = thisSMSAccountList[0]
        else:
            thisSMSAccount = SMSAccount()

        findRequest = Organization.query(
            Organization.strOrganizationID == thisAccount.strOrganizationID)
        thisOrgList = findRequest.fetch()

        if len(thisOrgList) > 0:
            thisOrg = thisOrgList[0]
        else:
            thisOrg = Organization()

        template = template_env.get_template(
            'templates/account/accountinfo.html')
        context = {
            'thisSMSAccount': thisSMSAccount,
            'thisAccount': thisAccount,
            'thisOrg': thisOrg
        }
        self.response.write(template.render(context))
Beispiel #13
0
    def post(self):

        from mysms import SMSAccount
        from accounts import Accounts, Organization
        vstrUserID = self.request.get("vstrUserID")
        vstrUserEmail = self.request.get('vstrUserEmail')
        vstraccessToken = self.request.get('vstraccessToken')

        findRequest = Accounts.query(Accounts.strUserID == vstrUserID)
        thisAccountList = findRequest.fetch()

        if len(thisAccountList) > 0:
            thisAccount = thisAccountList[0]
        else:
            findRequest = Accounts.query(Accounts.strEmail == vstrUserEmail,
                                         Accounts.strVerified == True)
            thisAccountList = findRequest.fetch()

            if len(thisAccountList) > 0:
                thisAccount = thisAccountList[0]
            else:
                thisAccount = Accounts()

        findRequest = SMSAccount.query(
            SMSAccount.strOrganizationID == thisAccount.strOrganizationID)
        thisSMSAccountList = findRequest.fetch()

        if len(thisSMSAccountList) > 0:
            thisSMSAccount = thisSMSAccountList[0]
        else:
            thisSMSAccount = SMSAccount()

        findRequest = Organization.query(
            Organization.strOrganizationID == thisAccount.strOrganizationID)
        thisOrgList = findRequest.fetch()

        if len(thisOrgList) > 0:
            thisOrg = thisOrgList[0]
        else:
            thisOrg = Organization()

        template = template_env.get_template('templates/sms/sub/admin.html')
        context = {
            'thisSMSAccount': thisSMSAccount,
            'thisAccount': thisAccount,
            'thisOrg': thisOrg,
            'vstrUserID': vstrUserID
        }
        self.response.write(template.render(context))
Beispiel #14
0
def load_all_projects(wf):
    log.debug('start updating the cache')
    wf = Workflow3()

    all_accounts = None
    try:
        all_accounts = Accounts(get_accounts(wf))
    except PasswordNotFound:  # API key has not yet been set
        notify("WARNING", "No API key saved")

        log.error('No API key saved')

    log.debug('loading accounts...')

    if not all_accounts:
        # just paste gitlab url to the variables page and token to the keychain and start using the workflow
        url = get_wf_variable(wf, "gitlab_url")
        token = get_wf_variable(wf, "gitlab_token")
        all_accounts = Account({
            "simple_account": {
                "url": url,
                "token": token,
                "project_membership": "true",
                "project_visibility": "internal",
            }
        })

    log.info('Removing cache: {}'.format(DATA_FILE))
    # if os.path.exists(DATA_FILE):
    #     return
    try:
        os.remove(DATA_FILE)
    except:
        pass

    result = []
    for acc_name, acc_settings in all_accounts.dict.items():
        log.info('base api url is: {url}; api token is: {token_name}'.format(
            url=acc_settings.url, token_name=acc_settings.token))
        result.extend(get_all_pages(wf, account=acc_settings))

    with open(DATA_FILE, 'w+') as fp:
        json.dump(result, fp)

    notify(
        "Cache was updated",
        "Was loaded {projects} projects from all gitlab instances".format(
            projects=len(result)))
Beispiel #15
0
    def __init__(self):
        wx.Frame.__init__(self, None, -1, "Budget ver. 1.0", size=(1100, 650))
        self.Centre(wx.BOTH)
        panel = wx.Panel(self, -1)

        notebook = wx.Notebook(panel)
        notebook.AddPage(Expenses(notebook), "Expenses")
        notebook.AddPage(Income(notebook), "Income")
        notebook.AddPage(Transfer(notebook), "Transfer")
        notebook.AddPage(Accounts(notebook), "Accounts")
        notebook.AddPage(Analysis(notebook), "Analysis")
        notebook.AddPage(Manage(notebook), "Manage")

        sizer = wx.BoxSizer()
        sizer.Add(notebook, 1, wx.EXPAND)
        panel.SetSizer(sizer)
Beispiel #16
0
 def inter(self):
     sql = """
         SELECT follow_uk,is_follow_crawler
         FROM yunpan.accounts
         WHERE is_follow_crawler is FALSE AND follow_count>0
         LIMIT 1
     """
     time.sleep(0.5)
     cursor = self.mysql_conn.cursor()
     cursor.execute(sql)
     result = cursor.fetchall()
     if result is not None and len(result) > 0:
         account = result[0][0]
     else:
         account = None
     while (account is not None):
         account = Accounts(account).execute()
Beispiel #17
0
    def get(self):
        Guser = users.get_current_user()
        if Guser:
            findRequest = Accounts.query(Accounts.strUserID == Guser.user_id())
            thisAccountsList = findRequest.fetch()

            if len(thisAccountsList) > 0:
                thisAccounts = thisAccountsList[0]
            else:
                thisAccounts = Accounts()

            findRequest = MailingList.query(MailingList.strOrganizationID == thisAccounts.strOrganizationID)
            thisMailingList = findRequest.fetch()

            template = template_env.get_template('templates/newsletter/newsletter.html')
            context = {'thisMailingList':thisMailingList}
            self.response.write(template.render(context))
Beispiel #18
0
import random, numpy

from net import Netter
from accounts import Accounts

random.seed(120)
ACCOUNTS = [('Account A','USD'),('Account B','EUR'),('Account C','USD'),('Account D','USD'),('Account E','EUR')]
CURRENCIES = ['AUD','CAD','CHF','GBP','EUR','HKD','JPY','NZD','PLN','USD']

if __name__ == "__main__":
    values = []
    count = 0
    totalSpread = 0
    totalSaving = 0
    for i in range(0,10000):
        accounts = Accounts(CURRENCIES)
        accounts.initAccounts(ACCOUNTS)
        spread = accounts.getSpreadCost()
        totalSpread += spread

        netter = Netter(accounts, True)
        saved, netOrders = netter.net()
        if (saved > 0 ):
            values.append((saved/spread)*100.0)
            totalSaving += saved
            count += 1

    print "Average saving is %5.2f on a flow of %5.2f" % (totalSaving/count, totalSpread/count)
    print "Average percent saving is %5.2f" % (totalSaving / totalSpread)
    values.sort()
    hist, bin_edges = numpy.histogram(values, 40)
 def setUp(self):
     '''
     this test runs before every test occurs
     '''
     self.new_account = Accounts('hamida', 'mstafa', 'mids', '1996')
Beispiel #20
0
 def __init__(self, oldMasterFile, newMasterFile, accountsFile):
     self.lastCommand = ''
     self.accounts = Accounts(oldMasterFile, newMasterFile, accountsFile)
Beispiel #21
0
def create_account(first_name, last_name, user_name, password):
    accounts = Accounts(first_name, last_name, user_name, password)
    return accounts
Beispiel #22
0
 def build(self):
     manager = ScreenManager()
     manager.add_widget(MyRoot(name='Login'))
     manager.add_widget(Accounts(name='Accounts'))
     manager.add_widget(Details(name='Details'))
     return manager
Beispiel #23
0
#import statements
import sys
sys.path.append('./twilio-api/')
sys.path.append('./app/')

from messages import Messages
from accounts import Accounts
from main_app import App
from tkinter import *
from datetime import datetime, timezone
import time

#instaniate objects for later use
messenger = Messages()
accountNumbers = Accounts()

app = App()


##### METHODS THAT WILL PROBABLY BE MOVED #####
def printSingleThread(number, accountNumber):
    messages = messenger.returnSingleThread(number, accountNumber)

    for message in messages:
        print("")
        print(message[1])
        print(message[2])
        print(message[3].strftime("%B %d, %Y %I:%M%p %Z"))

Beispiel #24
0
    def RouteLoginPost(self, route):
        from accounts import Accounts
        #from firebase_admin import auth

        if route == "email-not-verified":
            template = template_env.get_template(
                'templates/authentication/loggedin.html')
            context = {}
            self.response.write(template.render(context))

        elif route == "email-verified":
            template = template_env.get_template(
                'templates/authentication/loggedin.html')
            context = {}
            self.response.write(template.render(context))

        elif route == "user-not-loggedin":
            template = template_env.get_template(
                'templates/authentication/loggedout.html')
            context = {}
            self.response.write(template.render(context))

        elif route == "2":
            vstrDisplayName = self.request.get('vstrDisplayName')
            vstrEmail = self.request.get('vstrEmail')
            vstremailVerified = self.request.get('vstremailVerified')
            vstrUserID = self.request.get('vstrUserID')
            vstrPhoneNumber = self.request.get('vstrPhoneNumber')
            vstrProviderData = self.request.get('vstrProviderData')
            vstrAccessToken = self.request.get('vstrAccessToken')

            #decode_token = auth.verify_id_token(vstrAccessToken)
            #uid = decode_token['uid']

            findRequest = Accounts.query(Accounts.strUserID == vstrUserID)
            thisAccountList = findRequest.fetch()

            if len(thisAccountList) > 0:
                thisAccount = thisAccountList[0]
                thisAccount.writeEmail(strinput=vstrEmail)

            else:
                findRequest = Accounts.query(Accounts.strEmail == vstrEmail)
                thisAccountList = findRequest.fetch()
                if len(thisAccountList) > 0:
                    thisAccount = thisAccountList[0]
                    thisAccount.writeUserID(strinput=vstrUserID)
                else:
                    thisAccount = Accounts()
                    thisAccount.writeUserID(strinput=vstrUserID)
                    thisAccount.writeNames(strinput=vstrDisplayName)
                    thisAccount.writeEmail(strinput=vstrEmail)
                    thisAccount.writeProviderData(strinput=vstrProviderData)

            if vstremailVerified == "YES":
                thisAccount.writeVerified(strinput=True)
            else:
                thisAccount.writeVerified(strinput=False)
                thisAccount.writeUserID(strinput=vstrUserID)
                thisAccount.writeCell(strinput=vstrPhoneNumber)
                thisAccount.writeProviderData(strinput=vstrProviderData)

            thisAccount.writeAccessToken(strinput=vstrAccessToken)
            thisAccount.put()
Beispiel #25
0
        accounts_manager.Main()


if __name__ == '__main__':
    parser = optparse.OptionParser()
    parser.add_option('--daemon', dest='daemon', action='store_true')
    parser.add_option('--no-daemon', dest='daemon', action='store_false')
    # Leaving --interval flag for now to allow some time for each platform to move to
    # new flag
    parser.add_option('--interval', type='int', dest='interval')
    parser.add_option('--single-pass', dest='single_pass', action='store_true')
    parser.add_option('--no-single-pass',
                      dest='single_pass',
                      action='store_false')
    parser.add_option('--force', dest='force', action='store_true')
    parser.add_option('--debug', dest='debug', action='store_true')
    parser.set_defaults(interval=60)
    parser.set_defaults(single_pass=False)
    parser.set_defaults(daemon=False)
    parser.set_defaults(force=False)
    parser.set_defaults(debug=False)
    (options, args) = parser.parse_args()

    # set single_pass to True if interval is -1.
    if options.interval == -1:
        options.single_pass = True

    Main(Accounts(system_module=System()), DesiredAccounts(), System(),
         logging.getLogger(), None, LockFile(), None, options.single_pass,
         options.daemon, options.force, options.debug)
Beispiel #26
0
    def post(self):


        vstrChoice = self.request.get('vstrChoice')


        findRequest = Accounts.query(Accounts.strUserID == Guser.user_id())
        thisAccountsList = findRequest.fetch()

        if len(thisAccountsList) > 0:
            thisAccounts = thisAccountsList[0]
        else:
            thisAccounts = Accounts()

        vstrDateTime = datetime.datetime.now()
        strDate = vstrDateTime.date()
        strTime = datetime.time(hour=vstrDateTime.hour,minute=vstrDateTime.minute,second=vstrDateTime.second)

        if vstrChoice == "0":
            #'&vstrUserID=' + struid + '&vstrEmail=' + email + '&vstrAccessToken=' + accessToken;
            vstrUserID = self.request.get("vstrUserID")
            vstrEmail = self.request.get("vstrEmail")
            vstrAccessToken = self.request.get("vstrAccessToken")

            vstrListID = self.request.get('vstrListID')

            findRequest = Letters.query(Letters.strListID == vstrListID)
            thisLettersList = findRequest.fetch()

            template = template_env.get_template('templates/newsletter/sub/letters.html')
            context = {'thisLettersList':thisLettersList,'vstrListID':vstrListID}
            self.response.write(template.render(context))

        elif vstrChoice == "1":
            #+ '&vstrUserID=' + struid + '&vstrEmail=' + email + '&vstrAccessToken=' + accessToken;
            vstrUserID = self.request.get('vstrUserID')
            vstrEmail = self.request.get('vstrEmail')
            vstrAccessToken = self.request.get('vstrAccessToken')


            vstrLetterHeading = self.request.get('vstrLetterHeading')
            vstrLetterBody = self.request.get('vstrLetterBody')
            vstrListID = self.request.get('vstrListID')

            findRequest = Letters.query(Letters.strLetterHeading == vstrLetterHeading)
            thisLettersList = findRequest.fetch()

            if len(thisLettersList) > 0:
                thisLetter = thisLettersList[0]
            else:
                thisLetter = Letters()
                thisLetter.writeArticlesID(strinput=thisLetter.CreateArticleID())
                thisLetter.writeIndex(strinput=thisLetter.AdvanceIndex(strinput=vstrListID))
                thisLetter.writeHostedLink(strinput=thisLetter.CreateHostedLink())
                thisLetter.writeDateCreated(strinput=strDate)
                thisLetter.writeTimeCreated(strinput=strTime)
                thisLetter.writeMemberID(strinput=Guser.user_id())

            thisLetter.writeOrganizationID(strinput=thisAccounts.strOrganizationID)
            thisLetter.writeLetterHeading(strinput=vstrLetterHeading)
            thisLetter.writeLetterBody(strinput=vstrLetterBody)
            thisLetter.writeListID(strinput=vstrListID)

            thisLetter.put()

            self.response.write("Article successfully updated")

        elif vstrChoice == "2":
            #'&vstrUserID=' + struid + '&vstrEmail=' + email + '&vstrAccessToken=' + accessToken;
            vstrUserID = self.request.get("vstrUserID")
            vstrEmail = self.request.get("vstrEmail")
            vstrAccessToken = self.request.get("vstrAccessToken")


            vstrListID = self.request.get('vstrListID')

            findRequest = ContactList.query(ContactList.strListID == vstrListID)
            thisContactList = findRequest.fetch()

            template = template_env.get_template('templates/newsletter/sub/contact.html')
            context = {'thisContactList':thisContactList,'vstrListID':vstrListID}
            self.response.write(template.render(context))

        elif vstrChoice == "3":
            #'&vstrUserID=' + struid + '&vstrEmail=' + email + '&vstrAccessToken=' + accessToken;
            vstrUserID = self.request.get('vstrUserID')
            vstrEmail = self.request.get('vstrEmail')
            vstrAccessToken = self.request.get('vstrAccessToken')


            vstrListID = self.request.get('vstrListID')
            vstrContacts = self.request.get('vstrContacts')

            findRequest = Accounts.query(Accounts.strUserID == vstrUserID)
            thisAccountsList = findRequest.fetch()

            if len(thisAccountsList) > 0:
                thisAccounts = thisAccountsList[0]
            else:
                thisAccounts = Accounts()

            strContactList = vstrContacts.split("|")

            for thisContact in strContactList:
                thisContactList = thisContact.split(",")
                if len(thisContactList) == 4:
                    findRequest = ContactList.query(ContactList.strListID == vstrListID,ContactList.strEmail == thisContactList[1])
                    strthisContactList = findRequest.fetch()

                    if len(strthisContactList) > 0:
                        strContact = strthisContactList[0]
                    else:
                        strContact = ContactList()

                    strContact.writeListID(strinput=vstrListID)
                    strContact.writeCell(strinput=thisContactList[0])
                    strContact.writeEmail(strinput=thisContactList[1])
                    strContact.writeNames(strinput=thisContactList[2])
                    strContact.writeSurname(strinput=thisContactList[3])
                    strContact.writeOrganizationID(strinput=thisAccounts.strOrganizationID)
                    strContact.put()
            self.response.write("Contact list updated successfully")

        elif vstrChoice == "4":
            #'&vstrUserID=' + struid + '&vstrEmail=' + email + '&vstrAccessToken=' + accessToken;
            vstrUserID = self.request.get('vstrUserID')
            vstrEmail = self.request.get('vstrEmail')
            vstrAccessToken = self.request.get('vstrAccessToken')

            vstrListID = self.request.get('vstrListID')
            vstrNames = self.request.get('vstrNames')
            vstrSurname = self.request.get('vstrSurname')
            vstrCellNumber = self.request.get('vstrCellNumber')
            vstrEmail = self.request.get('vstrEmail')

            findRequest = Accounts.query(Accounts.strUserID == vstrUserID)
            thisAccountsList = findRequest.fetch()

            if len(thisAccountsList) > 0:
                thisAccounts = thisAccountsList[0]
            else:
                thisAccounts = Accounts()

            findRequest = ContactList.query(ContactList.strListID == vstrListID,ContactList.strEmail == vstrEmail)
            thisContactList = findRequest.fetch()

            if len(thisContactList) > 0:
                thisContact = thisContactList[0]
            else:
                thisContact = ContactList()

            thisContact.writeOrganizationID(strinput=thisAccounts.strOrganizationID)
            thisContact.writeListID(strinput=vstrListID)
            thisContact.writeNames(strinput=vstrNames)
            thisContact.writeSurname(strinput=vstrSurname)
            thisContact.writeCell(strinput=vstrCellNumber)
            thisContact.writeEmail(strinput=vstrEmail)
            thisContact.put()

            self.response.write("Successfully uploaded contact")

        elif vstrChoice == "5":
            #'&vstrUserID=' + struid + '&vstrEmail=' + email + '&vstrAccessToken=' + accessToken;
            vstrUserID = self.request.get('vstrUserID')
            vstrEmail = self.request.get('vstrEmail')
            vstrAccessToken = self.request.get('vstrAccessToken')

            vstrListID = self.request.get('vstrListID')
            vstrListID = vstrListID.strip()
            vstrRemoveEmail = self.request.get('vstrRemoveEmail')
            vstrRemoveEmail = vstrRemoveEmail.strip()

            findRequest = ContactList.query(ContactList.strEmail == vstrRemoveEmail,ContactList.strListID == vstrListID)
            thisContactList = findRequest.fetch()

            contactRemoved = False
            for thisContact in thisContactList:
                thisContact.key.delete()
                contactRemoved = True


            if contactRemoved:
                self.response.write("Successfully removed email")
            else:
                self.response.write("Contact not removed  :  " + vstrRemoveEmail)

        elif vstrChoice == "6":
            #'&vstrUserID=' + struid + '&vstrEmail=' + email + '&vstrAccessToken=' + accessToken;
            vstrUserID = self.request.get("vstrUserID")
            vstrEmail = self.request.get("vstrEmail")
            vstrAccessToken = self.request.get("vstrAccessToken")


            vstrListID = self.request.get('vstrListID')
            vstrListID = vstrListID.strip()

            findRequest = MailingList.query(MailingList.strListID == vstrListID)
            thisMailingList = findRequest.fetch()

            template = template_env.get_template('templates/newsletter/sub/schedule.html')
            context = {'thisMailingList':thisMailingList,'vstrListID':vstrListID}
            self.response.write(template.render(context))

        elif vstrChoice == "7":
            #+ '&vstrUserID=' + struid + '&vstrEmail=' + email + '&vstrAccessToken=' + accessToken;
            vstrUserID = self.request.get('vstrUserID')
            vstrEmail = self.request.get('vstrEmail')
            vstrAccessToken = self.request.get('vstrAccessToken')

            vstrListID = self.request.get('vstrListID')
            vstrDate = self.request.get('vstrDate')
            strDateList = vstrDate.split("/")
            strMonth = strDateList[0]
            strDay = strDateList[1]
            strYear = strDateList[2]
            vstrTime = self.request.get('vstrTime')
            if "AM" in vstrTime:
                vstrTime = vstrTime.replace("AM","")
                vstrTime = vstrTime.strip()
                strTimeList = vstrTime.split(":")
                strHour = strTimeList[0]
                strMinute = strTimeList[1]
            elif "PM" in vstrTime:
                vstrTime = vstrTime.replace("PM","")
                vstrTime = vstrTime.strip()
                strTimeList = vstrTime.split(":")
                strHour = strTimeList[0]
                strHour = int(strHour)
                strHour += 12
                strMinute = strTimeList[1]
            else:
                vstrTime = vstrTime.strip()
                strTimeList = vstrTime.split(":")
                strHour = strTimeList[0]
                strMinute = strTimeList[1]

            vstrThisDate = datetime.date(year=int(strYear),month=int(strMonth),day=int(strDay))
            vstrTime = datetime.time(hour=int(strHour),minute=int(strMinute))

            findRequest = MailingList.query(MailingList.strListID == vstrListID)
            thisMailingList = findRequest.fetch()

            if len(thisMailingList) > 0:
                thisMailing = thisMailingList[0]
                thisMailing.writeStartSendingDate(strinput=vstrThisDate)
                thisMailing.writeStartSendingTime(strinput=vstrTime)
                thisMailing.put()
                self.response.write("Successfully updated Scheduled date and time")
            else:
                self.response.write("Error updating scheduled date and time")
Beispiel #27
0
def create_account(fullname, username, password, phone_number, email):
    '''
        Function to create a new account
        '''
    new_account = Accounts("Ane kofi", "akofi", "12a", "22550", "*****@*****.**")
    return new_account
Beispiel #28
0
 def setUp(self):
     '''
     this test runs before every test occurs
     '''
     self.new_account = Accounts('dennis', 'kamau', 'Dk-denno', '4321')