tell ceod when it is a club rep; club reps don't need the new member email

This commit is contained in:
Jeremy Roman 2011-08-26 03:03:32 -04:00
parent e468fdcdbd
commit 0b3c9d835b
6 changed files with 51 additions and 28 deletions

View File

@ -114,7 +114,7 @@ def connected():
### Members ###
def create_member(username, password, name, program, email):
def create_member(username, password, name, program, email, club_rep=False):
"""
Creates a UNIX user account with options tailored to CSC members.
@ -123,7 +123,8 @@ def create_member(username, password, name, program, email):
password - the desired UNIX password
name - the member's real name
program - the member's program of study
email - email to place in .forward
club_rep - whether the user is a club rep
email - email to place in .forward
Exceptions:
InvalidArgument - on bad account attributes provided
@ -143,12 +144,16 @@ def create_member(username, password, name, program, email):
try:
request = ceo_pb2.AddUser()
request.type = ceo_pb2.AddUser.MEMBER
request.username = username
request.password = password
request.realname = name
request.program = program
request.email = email
request.email = email
if club_rep:
request.type = ceo_pb2.AddUser.CLUB_REP
else:
request.type = ceo_pb2.AddUser.MEMBER
out = remote.run_remote('adduser', request.SerializeToString())
@ -158,11 +163,6 @@ def create_member(username, password, name, program, email):
if any(message.status != 0 for message in response.messages):
raise MemberException('\n'.join(message.message for message in response.messages))
# # If the user was created, consider adding them to the mailing list
# if not status:
# listadmin_cfg_file = "/path/to/the/listadmin/config/file"
# mail = subprocess.Popen(["/usr/bin/listadmin", "-f", listadmin_cfg_file, "--add-member", username + "@csclub.uwaterloo.ca"])
# status2 = mail.wait() # Fuck if I care about errors!
except remote.RemoteException, e:
raise MemberException(e)
except OSError, e:

View File

@ -207,17 +207,29 @@ class EndPage(WizardPanel):
problem = None
try:
if self.utype == 'member':
members.create_member( self.state['userid'], self.state['password'], self.state['name'], self.state['program'], self.state['email'] )
members.register( self.state['userid'], self.state['terms'] )
members.create_member(
self.state['userid'],
self.state['password'],
self.state['name'],
self.state['program'],
self.state['email'])
members.register(self.state['userid'], self.state['terms'])
mailman_result = members.subscribe_to_mailing_list( self.state['userid'] )
mailman_result = members.subscribe_to_mailing_list(self.state['userid'])
if mailman_result.split(': ',1)[0] not in ('Subscribed', 'Already a member'):
problem = mailman_result
elif self.utype == 'clubuser':
members.create_member( self.state['userid'], self.state['password'], self.state['name'], self.state['program'], self.state['email'] )
members.register_nonmember( self.state['userid'], self.state['terms'] )
members.create_member(
self.state['userid'],
self.state['password'],
self.state['name'],
self.state['program'],
self.state['email'],
club_rep=True)
members.register_nonmember(self.state['userid'], self.state['terms'])
elif self.utype == 'club':
members.create_club( self.state['userid'], self.state['name'] )
members.create_club(self.state['userid'], self.state['name'])
else:
raise Exception("Internal Error")
except members.InvalidArgument, e:

View File

@ -19,7 +19,7 @@ h_from="$prog <ceo+$prog@csclub.uwaterloo.ca>"
h_to="Membership and Accounts <ceo@csclub.uwaterloo.ca>"
h_cc="$authrn <$auth@csclub.uwaterloo.ca>"
if test "$prog" = addmember; then
if [[ "$prog" = addmember || "$prog" == addclubrep ]]; then
user="$CEO_USER" name="$CEO_NAME" dept="$CEO_DEPT" status="$CEO_STATUS"
subj="New Member: $user"
test -z "$dept" && dept="things unknown"
@ -28,7 +28,7 @@ Account: $user
Program: $dept
Added by: $auth"
elif test "$prog" = addclub; then
elif [[ "$prog" = addclub ]]; then
user="$CEO_USER" name="$CEO_NAME" status="$CEO_STATUS"
subj="New Club Account: $user"
body="Club: $name

View File

@ -68,7 +68,7 @@ Regards,
Computer Science Club Executive
"
elif test "$prog" = addclub; then
elif [[ "$prog" = addclubrep || "$prog" = addclub ]]; then
exit 0
else
exit 1

View File

@ -9,6 +9,7 @@ message AddUser {
enum Type {
MEMBER = 1;
CLUB = 2;
CLUB_REP = 3;
}
required Type type = 1;

View File

@ -32,6 +32,7 @@ static const int MAX_MESGSIZE = 512;
char *user_types[] = {
[CEO__ADD_USER__TYPE__MEMBER] = "member",
[CEO__ADD_USER__TYPE__CLUB] = "club",
[CEO__ADD_USER__TYPE__CLUB_REP] = "clubrep",
};
Ceo__AddUserResponse *response_create(void) {
@ -94,16 +95,22 @@ static int check_adduser(Ceo__AddUser *in, Ceo__AddUserResponse *out, char *clie
if (!in->realname)
return response_message(out, EINVAL, "missing required argument: realname");
if (in->type == CEO__ADD_USER__TYPE__MEMBER) {
if (!in->password)
return response_message(out, EINVAL, "missing required argument: password");
} else if (in->type == CEO__ADD_USER__TYPE__CLUB) {
if (in->password)
return response_message(out, EINVAL, "club accounts cannot have passwords");
if (in->program)
return response_message(out, EINVAL, "club accounts cannot have programs");
} else {
return response_message(out, EINVAL, "invalid user type: %d", in->type);
switch (in->type) {
case CEO__ADD_USER__TYPE__MEMBER:
case CEO__ADD_USER__TYPE__CLUB_REP:
if (!in->password)
return response_message(out, EINVAL, "missing required argument: password");
break;
case CEO__ADD_USER__TYPE__CLUB:
if (in->password)
return response_message(out, EINVAL, "club accounts cannot have passwords");
if (in->program)
return response_message(out, EINVAL, "club accounts cannot have programs");
break;
default:
return response_message(out, EINVAL, "invalid user type: %d", in->type);
}
if (getpwnam(in->username) != NULL)
@ -244,6 +251,9 @@ static int32_t adduser(Ceo__AddUser *in, Ceo__AddUserResponse *out, char *client
if (in->type == CEO__ADD_USER__TYPE__MEMBER) {
status = addmember(in, out);
prog = "addmember";
} else if (in->type == CEO__ADD_USER__TYPE__CLUB_REP) {
status = addmember(in, out);
prog = "addclubrep";
} else if (in->type == CEO__ADD_USER__TYPE__CLUB) {
status = addclub(in, out);
prog = "addclub";