Ejemplo n.º 1
0
def deregister_event (username, event_id):
    pick = rP(EVENT_REGISTER)
    elist = pick.get(username, [])
    while event_id in elist:
        del elist[elist.index(event_id)]
    pick[username] = elist
    wP(pick, EVENT_REGISTER)
Ejemplo n.º 2
0
def cache_role (username, role, action):
    if username:
        username = username.lower()
        REG = ''
        if role == 'resident':
            REG = RESD_REGISTER
        if role == 'diplomate':
            REG = DIPL_REGISTER
        if role == 'emeritus':
            REG = EMER_REGISTER
        if role == 'honorary':
            REG = HONO_REGISTER
        if role == 'memoriam':
            REG = MEMO_REGISTER
        if REG:
            L = rP(REG)
            if not L: L = []
            if action == 'reg':
                if username not in L:
                    L.append(username)
                    wP(L, REG)
            if action == 'dereg':
                if username in L:
                    del L[L.index(username)]
                    wP(L, REG)
Ejemplo n.º 3
0
def cache_role(username, role, action):
    if username:
        username = username.lower()
        REG = ''
        if role == 'resident':
            REG = RESD_REGISTER
        if role == 'diplomate':
            REG = DIPL_REGISTER
        if role == 'emeritus':
            REG = EMER_REGISTER
        if role == 'honorary':
            REG = HONO_REGISTER
        if role == 'memoriam':
            REG = MEMO_REGISTER
        if REG:
            L = rP(REG)
            if not L: L = []
            if action == 'reg':
                if username not in L:
                    L.append(username)
                    wP(L, REG)
            if action == 'dereg':
                if username in L:
                    del L[L.index(username)]
                    wP(L, REG)
Ejemplo n.º 4
0
def get_user_events (username):
    evs = []
    rg = rP(EVENT_REGISTER)
    if rg.has_key(username):
        if rg.get(username):
            evs = rg.get(username)
    return evs
Ejemplo n.º 5
0
def get_annual_news():
    AN = []
    all = glob.glob(os.path.join(AMTGDIR, '*'))
    all.sort()
    all.reverse()
    for x in all:
        AN.append(rP(os.path.join(x)))
    return AN
Ejemplo n.º 6
0
def register_email_addr(email, userid):
    # duplicate email addresses should have already been checked
    if email:
        email = email.lower()
        d = rP(EMAIL_REGISTER)
        if not d.has_key(email):
            d[email] = userid
        wP(d, EMAIL_REGISTER)
Ejemplo n.º 7
0
def get_action_items():
    AN = []
    all = glob.glob(os.path.join(ACTIDIR, '*'))
    all.sort()
    all.reverse()
    for x in all:
        AN.append(rP(os.path.join(x)))
    return AN
Ejemplo n.º 8
0
def get_annual_news():
    AN = []
    all = glob.glob(os.path.join(AMTGDIR, '*'))
    all.sort()
    all.reverse()
    for x in all:
        AN.append(rP(os.path.join(x)))
    return AN
Ejemplo n.º 9
0
def register_email_addr (email, userid):
    # duplicate email addresses should have already been checked
    if email:
        email = email.lower()
        d = rP(EMAIL_REGISTER)
        if not d.has_key(email):
            d[email] = userid
        wP(d, EMAIL_REGISTER)
Ejemplo n.º 10
0
def get_action_items():
    AN = []
    all = glob.glob(os.path.join(ACTIDIR, '*'))
    all.sort()
    all.reverse()
    for x in all:
        AN.append(rP(os.path.join(x)))
    return AN
Ejemplo n.º 11
0
def get_event_info (id):
    pick = rP(os.path.join(EVENTDIR, id))
    t = time.gmtime(int(id))
    pick['dayofweek'] = time.strftime('%a', t)
    pick['display_date'] = time.strftime('%A, %B %d, %Y', t)
    pick['month'] = time.strftime('%B', t)
    pick['day'] = str(t[2])
    pick['year'] = str(t[0])
    return pick
Ejemplo n.º 12
0
def save_doc_access (filename, role):
    # One role at a time, please.
    # {role: [list,of,filenames], other: [], }
    p = rP(ACCESS_FILE)
    file_list = p.get(role, [])
    if filename not in file_list:
        file_list.append(filename)
        p[role] = file_list
        wP(p, ACCESS_FILE)
Ejemplo n.º 13
0
def save_doc_to_category (filename, category):
    # One category at a time, please.
    # {categoryname: [list,of,filenames], other: [], }
    p = rP(CATEGORIES_FILE)
    file_list = p.get(category, [])
    if filename not in file_list:
        file_list.append(filename)
        p[category] = file_list
        wP(p, CATEGORIES_FILE)
Ejemplo n.º 14
0
def archive_document (doctype, category, filename):
    # This adds if not in list, removes if in list. Toggle status, basically.
    dd = get_doc_dir(doctype, category)
    archfile = os.path.join(dd, '.archivelist')
    archivelist = rP(archfile)
    if not archivelist:
        archivelist = []
    if filename not in archivelist:
        archivelist.append(filename)
    else:
        del archivelist[archivelist.index(filename)]
    wP(archivelist, archfile)
Ejemplo n.º 15
0
    def writeContent(self):
        wr = self.writeln
        qs = self.request().fields()
        ISA = is_site_admin(self.request())
        wr('<h1>%s</h1>' % (self.title()))
        linksdict = rP(LINKFILE)

        if self.request()._environ.get('REQUEST_METHOD') == 'POST':
            form = qs
            u = form.get('url')
            if not u.startswith('http://'):
                form['url'] = 'http://' + u
            linkid = str(int(time.time()))
            
            linksdict[linkid] = form
            wP(linksdict, LINKFILE)
            self.response().sendRedirect("Links")

        else:
            if qs.get('delete_link_id'):
                timeid = qs['delete_link_id']
                
                del linksdict[qs.get('delete_link_id')]
                wP(linksdict, LINKFILE)
                self.response().sendRedirect("Links")

            else: # display
                if ISA:
                    wr('<P><table>')
                    wr('<form action="Links" method="POST"><tr><td colspan="2"><b>Add Link</b><br>')
                    wr('<tr><td>Title to display:<td><input type="text" name="title" value=""><br>')
                    wr('<tr><td>Web Address:<td><input type="text" name="url" value=""><br>')
                    wr('<tr><td colspan="2"><input type="submit" value="Add Link">')
                    wr('</table></form>')
                    wr('</P>')
                
                if linksdict:
                    titlesandids = []
                    for timeid in linksdict.keys():
                        d = linksdict[timeid]
                        t = (d.get('title'), timeid)
                        titlesandids.append(t)
                    titlesandids.sort()

                    for title, timeid in titlesandids:
                        url = linksdict[timeid].get('url')
                        wr('<P><a href="%s">%s</a>' % (url, title))
                        if ISA:
                            wr('<a href="Links?delete_link_id=%s"><img src="/g/delete.png" alt="delete" width="17" height="17" border="0" /></a>' % (timeid))
                        wr('</P>')
                else:
                    wr('<P>Sorry, there are no links right now.</P>')
Ejemplo n.º 16
0
def get_news_by_year (year=None):
    if not year:
        year = now_year()
    MATCH = []
    all = glob.glob(os.path.join(NEWSDIR, '*'))
    all.sort()
    all.reverse()
    for nipath in all:
        niname = os.path.basename(nipath)
        niyear = str(time.localtime(int(niname))[0])
        if niyear == year:
            MATCH.append(rP(os.path.join(nipath)))
    return MATCH
Ejemplo n.º 17
0
def get_news_by_year(year=None):
    if not year:
        year = now_year()
    MATCH = []
    all = glob.glob(os.path.join(NEWSDIR, '*'))
    all.sort()
    all.reverse()
    for nipath in all:
        niname = os.path.basename(nipath)
        niyear = str(time.localtime(int(niname))[0])
        if niyear == year:
            MATCH.append(rP(os.path.join(nipath)))
    return MATCH
Ejemplo n.º 18
0
def get_user_acct(username, with_pass=False):
    if username:
        username = username.lower()
        a = os.path.join(ACCTDIR, username)
        if os.path.exists(a):
            b = rP(a)
            if not with_pass:
                if b.has_key('password'):
                    del b['password']
            return b
        else:
            return {}
    else:
        return {}
Ejemplo n.º 19
0
def get_user_acct (username, with_pass=False):
    if username:
        username = username.lower()
        a = os.path.join(ACCTDIR, username)
        if os.path.exists(a):
            b = rP(a)
            if not with_pass:
                if b.has_key('password'):
                    del b['password']
            return b
        else:
            return {}
    else:
        return {}
Ejemplo n.º 20
0
def fstates ():
    allaccts = glob.glob(os.path.join(ADIR, '*'))
    for fpath in allaccts:
        p = rP(fpath)
        ct = p.get('country')
        st = p.get('state')
        if ct == 'USA':
            if st not in USA_STATES_LOOKUP.keys():
                print '%s (USA) state is %s' % (os.path.basename(fpath), st)
        if ct == 'Canada':
            if st not in CAN_STATES_LOOKUP.keys():
                print '%s (CAN) state is %s' % (os.path.basename(fpath), st)
        if ct == 'Mexico':
            if st not in MEX_STATES_LOOKUP.keys():
                print '%s (MEX) state is %s' % (os.path.basename(fpath), st)
Ejemplo n.º 21
0
def get_users (utype):
    if utype in ['diplomate', 'diplomates', 'd']:
        REG = DIPL_REGISTER
    elif utype in ['resident', 'residents', 'r']:
        REG = RESD_REGISTER
    elif utype in ['emeritus', 'e']:
        REG = EMER_REGISTER
    elif utype in ['honorary', 'h']:
        REG = HONO_REGISTER
    elif utype in ['memoriam', 'm']:
        REG = MEMO_REGISTER
    else:
        return {}

    L = rP(REG)
    FINAL = {}
    for username in L:
        upick = get_user_acct(username)
        upick['username'] = username
        uuid = '%s_%s_%s' % (upick.get('sn'), upick.get('fn'), username)
        FINAL[uuid] = upick
    return FINAL
Ejemplo n.º 22
0
def get_users(utype):
    if utype in ['diplomate', 'diplomates', 'd']:
        REG = DIPL_REGISTER
    elif utype in ['resident', 'residents', 'r']:
        REG = RESD_REGISTER
    elif utype in ['emeritus', 'e']:
        REG = EMER_REGISTER
    elif utype in ['honorary', 'h']:
        REG = HONO_REGISTER
    elif utype in ['memoriam', 'm']:
        REG = MEMO_REGISTER
    else:
        return {}

    L = rP(REG)
    FINAL = {}
    for username in L:
        upick = get_user_acct(username)
        upick['username'] = username
        uuid = '%s_%s_%s' % (upick.get('sn'), upick.get('fn'), username)
        FINAL[uuid] = upick
    return FINAL
Ejemplo n.º 23
0
def register(regfile, filename, title):
    r = rP(regfile)
    r[filename] = title
    wP(r, regfile)
Ejemplo n.º 24
0
def get_constitution_info():
    return rP(DOC_CONST_INFO)
Ejemplo n.º 25
0
def get_journal_access ():
    return rP(JOURNALIST)
Ejemplo n.º 26
0
def get_all_possible_categories ():
    return rP(MASTER_CATEGORY_LIST)
Ejemplo n.º 27
0
def unregister (regfile, filename):
    r = rP(regfile)
    if filename in r.keys():
        del r[filename]
    wP(r, regfile)
Ejemplo n.º 28
0
def get_constitution_info ():
    return rP(DOC_CONST_INFO)
Ejemplo n.º 29
0
def get_categories ():
    return rP(CATEGORIES_FILE)
Ejemplo n.º 30
0
def get_access ():
    return rP(ACCESS_FILE)
Ejemplo n.º 31
0
def get_titles ():
    return rP(TITLES_FILE)
Ejemplo n.º 32
0
def register_event (username, event_id):
    pick = rP(EVENT_REGISTER)
    if not pick.has_key(username):
        pick[username] = []
    pick[username].append(event_id)
    wP(pick, EVENT_REGISTER)
Ejemplo n.º 33
0
def is_email_registered (email):
    if email:
        email = email.lower()
        d = rP(EMAIL_REGISTER)
        return email in d.keys()
Ejemplo n.º 34
0
def get_descriptions ():
    return rP(DESC_FILE)
Ejemplo n.º 35
0
def is_email_registered(email):
    if email:
        email = email.lower()
        d = rP(EMAIL_REGISTER)
        return email in d.keys()
Ejemplo n.º 36
0
def unregister(regfile, filename):
    r = rP(regfile)
    if filename in r.keys():
        del r[filename]
    wP(r, regfile)
Ejemplo n.º 37
0
def get_doc_dict(dtype, dcat=None):
    pd = get_doc_dir(dtype, dcat)
    if pd:
        return (os.path.basename(pd), rP(os.path.join(pd, '.info')))
Ejemplo n.º 38
0
def get_news_item (id):
    for ddir in (NEWSDIR, AMTGDIR, ACTIDIR):
        p = os.path.join(ddir, id)
        if os.path.exists(p):
            return rP(p)
Ejemplo n.º 39
0
def register (regfile, filename, title):
    r = rP(regfile)
    r[filename] = title
    wP(r, regfile)
Ejemplo n.º 40
0
def get_news_item(id):
    for ddir in (NEWSDIR, AMTGDIR, ACTIDIR):
        p = os.path.join(ddir, id)
        if os.path.exists(p):
            return rP(p)
Ejemplo n.º 41
0
def get_doc_dict (dtype, dcat=None):
    pd = get_doc_dir(dtype, dcat)
    if pd:
        return ( os.path.basename(pd), rP(os.path.join(pd, '.info')) )
Ejemplo n.º 42
0
def unregister_email_addr(userid):
    d = rP(EMAIL_REGISTER)
    for k in d.keys():
        if d[k] == userid:
            del d[k]
    wP(d, EMAIL_REGISTER)
Ejemplo n.º 43
0
def get_archive_list (doctype, category):
    dd = get_doc_dir(doctype, category)
    archfile = os.path.join(dd, '.archivelist')
    return rP(archfile)
Ejemplo n.º 44
0
def unregister_email_addr (userid):
    d = rP(EMAIL_REGISTER)
    for k in d.keys():
        if d[k] == userid:
            del d[k]
    wP(d, EMAIL_REGISTER)