forked from public/pyceo
tell ceod when it is a club rep; club reps don't need the new member email
This commit is contained in:
parent
e468fdcdbd
commit
0b3c9d835b
|
@ -114,7 +114,7 @@ def connected():
|
||||||
|
|
||||||
### Members ###
|
### 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.
|
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
|
password - the desired UNIX password
|
||||||
name - the member's real name
|
name - the member's real name
|
||||||
program - the member's program of study
|
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:
|
Exceptions:
|
||||||
InvalidArgument - on bad account attributes provided
|
InvalidArgument - on bad account attributes provided
|
||||||
|
@ -143,12 +144,16 @@ def create_member(username, password, name, program, email):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
request = ceo_pb2.AddUser()
|
request = ceo_pb2.AddUser()
|
||||||
request.type = ceo_pb2.AddUser.MEMBER
|
|
||||||
request.username = username
|
request.username = username
|
||||||
request.password = password
|
request.password = password
|
||||||
request.realname = name
|
request.realname = name
|
||||||
request.program = program
|
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())
|
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):
|
if any(message.status != 0 for message in response.messages):
|
||||||
raise MemberException('\n'.join(message.message 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:
|
except remote.RemoteException, e:
|
||||||
raise MemberException(e)
|
raise MemberException(e)
|
||||||
except OSError, e:
|
except OSError, e:
|
||||||
|
|
|
@ -207,17 +207,29 @@ class EndPage(WizardPanel):
|
||||||
problem = None
|
problem = None
|
||||||
try:
|
try:
|
||||||
if self.utype == 'member':
|
if self.utype == 'member':
|
||||||
members.create_member( self.state['userid'], self.state['password'], self.state['name'], self.state['program'], self.state['email'] )
|
members.create_member(
|
||||||
members.register( self.state['userid'], self.state['terms'] )
|
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'):
|
if mailman_result.split(': ',1)[0] not in ('Subscribed', 'Already a member'):
|
||||||
problem = mailman_result
|
problem = mailman_result
|
||||||
|
|
||||||
elif self.utype == 'clubuser':
|
elif self.utype == 'clubuser':
|
||||||
members.create_member( self.state['userid'], self.state['password'], self.state['name'], self.state['program'], self.state['email'] )
|
members.create_member(
|
||||||
members.register_nonmember( self.state['userid'], self.state['terms'] )
|
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':
|
elif self.utype == 'club':
|
||||||
members.create_club( self.state['userid'], self.state['name'] )
|
members.create_club(self.state['userid'], self.state['name'])
|
||||||
else:
|
else:
|
||||||
raise Exception("Internal Error")
|
raise Exception("Internal Error")
|
||||||
except members.InvalidArgument, e:
|
except members.InvalidArgument, e:
|
||||||
|
|
|
@ -19,7 +19,7 @@ h_from="$prog <ceo+$prog@csclub.uwaterloo.ca>"
|
||||||
h_to="Membership and Accounts <ceo@csclub.uwaterloo.ca>"
|
h_to="Membership and Accounts <ceo@csclub.uwaterloo.ca>"
|
||||||
h_cc="$authrn <$auth@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"
|
user="$CEO_USER" name="$CEO_NAME" dept="$CEO_DEPT" status="$CEO_STATUS"
|
||||||
subj="New Member: $user"
|
subj="New Member: $user"
|
||||||
test -z "$dept" && dept="things unknown"
|
test -z "$dept" && dept="things unknown"
|
||||||
|
@ -28,7 +28,7 @@ Account: $user
|
||||||
Program: $dept
|
Program: $dept
|
||||||
Added by: $auth"
|
Added by: $auth"
|
||||||
|
|
||||||
elif test "$prog" = addclub; then
|
elif [[ "$prog" = addclub ]]; then
|
||||||
user="$CEO_USER" name="$CEO_NAME" status="$CEO_STATUS"
|
user="$CEO_USER" name="$CEO_NAME" status="$CEO_STATUS"
|
||||||
subj="New Club Account: $user"
|
subj="New Club Account: $user"
|
||||||
body="Club: $name
|
body="Club: $name
|
||||||
|
|
|
@ -68,7 +68,7 @@ Regards,
|
||||||
|
|
||||||
Computer Science Club Executive
|
Computer Science Club Executive
|
||||||
"
|
"
|
||||||
elif test "$prog" = addclub; then
|
elif [[ "$prog" = addclubrep || "$prog" = addclub ]]; then
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -9,6 +9,7 @@ message AddUser {
|
||||||
enum Type {
|
enum Type {
|
||||||
MEMBER = 1;
|
MEMBER = 1;
|
||||||
CLUB = 2;
|
CLUB = 2;
|
||||||
|
CLUB_REP = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
required Type type = 1;
|
required Type type = 1;
|
||||||
|
|
|
@ -32,6 +32,7 @@ static const int MAX_MESGSIZE = 512;
|
||||||
char *user_types[] = {
|
char *user_types[] = {
|
||||||
[CEO__ADD_USER__TYPE__MEMBER] = "member",
|
[CEO__ADD_USER__TYPE__MEMBER] = "member",
|
||||||
[CEO__ADD_USER__TYPE__CLUB] = "club",
|
[CEO__ADD_USER__TYPE__CLUB] = "club",
|
||||||
|
[CEO__ADD_USER__TYPE__CLUB_REP] = "clubrep",
|
||||||
};
|
};
|
||||||
|
|
||||||
Ceo__AddUserResponse *response_create(void) {
|
Ceo__AddUserResponse *response_create(void) {
|
||||||
|
@ -94,16 +95,22 @@ static int check_adduser(Ceo__AddUser *in, Ceo__AddUserResponse *out, char *clie
|
||||||
if (!in->realname)
|
if (!in->realname)
|
||||||
return response_message(out, EINVAL, "missing required argument: realname");
|
return response_message(out, EINVAL, "missing required argument: realname");
|
||||||
|
|
||||||
if (in->type == CEO__ADD_USER__TYPE__MEMBER) {
|
switch (in->type) {
|
||||||
if (!in->password)
|
case CEO__ADD_USER__TYPE__MEMBER:
|
||||||
return response_message(out, EINVAL, "missing required argument: password");
|
case CEO__ADD_USER__TYPE__CLUB_REP:
|
||||||
} else if (in->type == CEO__ADD_USER__TYPE__CLUB) {
|
if (!in->password)
|
||||||
if (in->password)
|
return response_message(out, EINVAL, "missing required argument: password");
|
||||||
return response_message(out, EINVAL, "club accounts cannot have passwords");
|
break;
|
||||||
if (in->program)
|
|
||||||
return response_message(out, EINVAL, "club accounts cannot have programs");
|
case CEO__ADD_USER__TYPE__CLUB:
|
||||||
} else {
|
if (in->password)
|
||||||
return response_message(out, EINVAL, "invalid user type: %d", in->type);
|
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)
|
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) {
|
if (in->type == CEO__ADD_USER__TYPE__MEMBER) {
|
||||||
status = addmember(in, out);
|
status = addmember(in, out);
|
||||||
prog = "addmember";
|
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) {
|
} else if (in->type == CEO__ADD_USER__TYPE__CLUB) {
|
||||||
status = addclub(in, out);
|
status = addclub(in, out);
|
||||||
prog = "addclub";
|
prog = "addclub";
|
||||||
|
|
Loading…
Reference in New Issue