Пример #1
0
    def form_new_users(self, csv_fname, college_group):
        "Create the new user objects -- not in db yet."
        rows = self.read_csv( csv_fname )

        # Returns dictionary
        # keys are columns, values are column numbers
        colmap = self.discover_columns(rows)

        newusers = []

        for row in rows:
            fname, lname, email = [row[colmap[x]] for x in ["fname", "lname", "email"]]

            tmpset = [x.username for x in newusers]
            uname = sr.new_username(college_group, fname, lname, tmpset)
            u = sr.user( uname )
            u.cname = fname.strip().capitalize()
            u.sname = lname.strip().capitalize()
            u.email = email.strip().lower()
            newusers.append(u)

        return newusers
Пример #2
0
    def form_new_users(self, csv_fname, college_group):
        "Create the new user objects -- not in db yet."
        rows = self.read_csv( csv_fname )

        # Returns dictionary
        # keys are columns, values are column numbers
        colmap = self.discover_columns(rows)

        newusers = []

        for row in rows:
            fname, lname, email = [row[colmap[x]] for x in ["fname", "lname", "email"]]

            tmpset = [x.username for x in newusers]
            uname = sr.new_username(college_group, fname, lname, tmpset)
            u = sr.user( uname )
            u.cname = fname.strip().capitalize()
            u.sname = lname.strip().capitalize()
            u.email = email.strip().lower()
            newusers.append(u)

        return newusers
Пример #3
0
    teamGroups = []
    for team in teams:
        teamGroup = c_teams.get_team(team)
        teamGroups.append(teamGroup)

    if college.in_db or len([x for x in teamGroups if x.in_db]) != 0:
        print >>sys.stderr, "College {0} or associated teams already in db, skipping import".format(college_tla)
        skipped += 1
        continue

    print >>sys.stderr, "Creating groups + account for {0}".format(college_tla)

    # Split at most once -- assume additional name parts go in the last name
    first_name, last_name = team_leader['name'].split(' ', 1)
    newname = sr.new_username(college_tla, first_name, last_name)
    u = sr.users.user(newname)

    u.cname = first_name
    u.sname = last_name
    u.email = team_leader['email']
    u.save()
    u.set_lang('english')
    u.save()

    college.user_add(u)
    college.desc = team_name
    college.save()

    for team in teamGroups:
        team.user_add(u)
Пример #4
0
    college = c_teams.get_college(college_tla)

    teamGroups = []
    for team in teams:
        teamGroup = c_teams.get_team(team)
        teamGroups.append(teamGroup)

    if college.in_db or len([x for x in teamGroups if x.in_db]) != 0:
        print >>sys.stderr, "College {0} or associated teams already in db, skipping import".format(college_tla)
        skipped += 1
        continue

    print >>sys.stderr, "Creating groups + account for {0}".format(college_tla)

    first_name, last_name = the_contact['name'].split(' ')
    newname = sr.new_username(college_tla, first_name, last_name)
    u = sr.users.user(newname)

    u.cname = first_name
    u.sname = last_name
    u.email = the_contact['email']
    u.save()
    u.set_lang('english')
    u.save()

    college.user_add(u)
    college.save()

    for team in teamGroups:
        team.user_add(u)
        team.save()
Пример #5
0
#!/usr/bin/python

import sys
import csv
import sr
import c_teams
import mailer

if len(sys.argv) != 2:
    print >>sys.stderr, "Usage: importusers.py users.csv"
    sys.exit(1)

for row in csv.reader(open(sys.argv[1], 'r')):
    print repr(row)
    newname = sr.new_username(row[2], row[3], row[4])
    u =sr.users.user(newname)
    if u.in_db:
        print >>sys.stderr, "User {0} already exists".format(newname)
        sys.exit(1)

    college = sr.group(row[2])
    if not college.in_db:
        print >>sys.stderr, "Group {0} doesn't exist".format(row[2])
        sys.exit(1)

    team = sr.group(row[6])
    if not team.in_db:
        print >>sys.stderr, "Group {0} doesn't exist".format(row[2])
        sys.exit(1)

    students = sr.group('students')