def get(self, groupname): profile = socialdata.get_user_profile(helpers.get_user_email()) if not profile: #if the user does not have a profile, go to home self.redirect('/') else: #otherwise, allow them to create group errorText = "" values = helpers.get_template_parameters() groups = group_data.get_groups_by_courses(profile.courses) listOfGroupNames = [] membersList = membership_data.get_members_from_group(groupname) for group in groups: if ((group.member_limit) - len(membersList) + 1) < 1: errorText += "The member limit has been reached." elif profile.email in membersList: errorText += "You are already in this group." else: listOfGroupNames.append(group.name) values['name'] = profile.name values['groups'] = listOfGroupNames if errorText: values['errormsg'] = errorText else: membership_data.save_membership(helpers.get_user_email(), groupname) self.redirect("/group-list") values['successmsg'] = "Everything worked out fine." helpers.render_template(self, 'group-list.html', values) #show group creation page
def get(self): values = helpers.get_template_parameters() if helpers.get_user_email(): #checks to see if signed in profile = socialdata.get_user_profile(helpers.get_user_email()) if profile: #if the profile exists, we can click on profile-view values['name'] = profile.name helpers.render_template(self, 'mainpage.html', values) # shows page
def post(self): profile = socialdata.get_user_profile( helpers.get_user_email()) #we get a profile if not profile: #if the profile doesn't exist, we kick them out self.redirect('/') else: error_text = '' #initializes an empty error group_name = self.request.get("group_name") course = self.request.get("course") description = self.request.get("description") member_limit = self.request.get( "quantity") #lines 35 - 42 set default values in group group_admin = helpers.get_user_email() meet = self.request.get("meet") time = self.request.get("time") school = profile.school values = helpers.get_template_parameters() group_name.strip() #lines 49- 57 are name nonos group_name.replace(" ", "&") if (len(group_name) < 1) or (len(course) < 1) or ( len(description) < 1) or (len(member_limit) < 1): error_text += "Make sure all fields are filled" for i in group_name: if i == '?': error_text += "Your name can't have ' ? '\n" elif i == '\\': error_text += "Your name can't have ' \\ '\n" elif i == '/': error_text += "Your name can't have ' / '\n" elif i == '.': error_text += "Your name can't have ' . '\n" elif i == '#': error_text += "Your name can't have ' # '\n" values['group_name'] = group_name #set template values values['courses'] = profile.courses values['description'] = description values['member_limit'] = member_limit values['name'] = profile.name values['meeting_date'] = meet values['meeting_time'] = time if group_data.get_group_by_name(group_name): error_text += "This group name is already taken" if error_text: #print error text if there's a problem values['errormsg'] = error_text else: membership_data.save_membership(helpers.get_user_email(), group_name) group_data.save_group( group_name, description, course, int(member_limit), group_admin, school, meet, time) #print success message if no problem saving values['successmsg'] = "Success!" helpers.render_template(self, 'group-edit.html', values) #go back to edit render
def get(self): if not helpers.get_user_email( ): # if they don't have an email, we kick em self.redirect('/') else: values = helpers.get_template_parameters() profile = socialdata.get_user_profile(helpers.get_user_email()) if profile: # if they do have a profile, we populate it with default values values['name'] = profile.name values['school'] = profile.school values['courses'] = profile.courses helpers.render_template(self, 'profile-edit.html', values) # shows the profile-edit page
def get(self, groupname): profile = socialdata.get_user_profile(helpers.get_user_email()) if not profile: #if the user does not have a profile, go to home self.redirect('/') else: membership_data.delete_membership(profile.email, groupname) self.redirect('/group-list')
def get(self): profile = socialdata.get_user_profile(helpers.get_user_email()) if not profile: #if the user does not have a profile, go to home self.redirect('/') else: #otherwise, allow them to create group errorText = '' values = helpers.get_template_parameters() groups = group_data.get_groups_by_courses(profile.courses) listOfGroupNames = [] for group in groups: membersList = membership_data.get_members_from_group( group.name) if ((group.member_limit) - len(membersList) + 1) < 1: errorText += "The member limit has been reached." elif profile.email in membersList: errorText += "You are already in this group." else: listOfGroupNames.append(group.name) listOfInGroups = membership_data.get_groups_from_member( profile.email) listOfInGroupsNoAdmin = [] if len(listOfInGroups) > 0: for group in listOfInGroups: if group_data.get_group_by_name( group).group_admin != profile.email: listOfInGroupsNoAdmin.append(group) values['name'] = profile.name listOfNames = [] for group in group_data.get_admin_groups(profile.email): listOfNames.append(group.name) values["admin_groups"] = listOfNames values['groups'] = listOfGroupNames values["ingroups"] = listOfInGroupsNoAdmin helpers.render_template(self, 'group-list.html', values) #show group creation page
def get(self): profile = socialdata.get_user_profile(helpers.get_user_email()) if not profile: #at this point, they should have a profile. If they don't, kick 'em self.redirect('/') else: values = helpers.get_template_parameters() values['courses'] = profile.courses helpers.render_template(self, 'group-edit.html', values) #the page is rendered
def get(self, groupname): profile = socialdata.get_user_profile(helpers.get_user_email()) if not (profile.email == group_data.get_group_by_name(groupname). group_admin): #if the user does not have a profile, go to home self.redirect('/') else: membership_data.delete_all_membership(groupname) values = helpers.get_template_parameters() values['name'] = profile.name listOfNames = [] for group in group_data.get_admin_groups(profile.email): listOfNames.append(group.name) values["groups"] = listOfNames helpers.render_template(self, 'group-create.html', values) #show group creation page
def post(self): email = helpers.get_user_email() if not email: # if they don't have an email, we kick em self.redirect('/') else: error_text = '' # intialize an empty error text name = self.request.get("name") # gets values from form school = self.request.get("school") values = helpers.get_template_parameters() name.strip() name.replace(" ", "&") # Restricts the name choices for the user if len(name) > 60: error_text += "Your name can't be more than 60 letters\n" for i in name: if i == '?': error_text += "Your name can't have ' ? '\n" elif i == '\\': error_text += "Your name can't have ' \\ '\n" elif i == '/': error_text += "Your name can't have ' / '\n" elif i == '.': error_text += "Your name can't have ' . '\n" values['name'] = name coursesList = [] # code for showing repeated courses coursenum = 0 course = self.request.get("classes0") while course: coursesList.append(course) coursenum += 1 course = self.request.get("classes" + str(coursenum)) values['courses'] = coursesList values['school'] = school if error_text: values['errormsg'] = error_text else: socialdata.save_profile( name, email, coursesList, school) # save profile if everything is fine values['successmsg'] = "Success!" helpers.render_template(self, 'profile-edit.html', values) #show page
def get(self, groupname): group = group_data.get_group_by_name(groupname) values = helpers.get_template_parameters() values['groupname'] = 'Unknown' values['course'] = "no course" values['school'] = "no school" values['description'] = "no description" values['admin'] = "unknown admin" values["members"] = "unkown members" profile = socialdata.get_user_profile(helpers.get_user_email()) values['name'] = profile.name if group: values['groupname'] = group.name values['course'] = group.course values['school'] = group.school values['description'] = group.description values['meeting_date'] = group.meet values['meeting_time'] = group.time values['admin'] = group.group_admin values["members"] = membership_data.get_members_from_group( groupname) helpers.render_template(self, 'group-view.html', values)
def get(self): profile = socialdata.get_user_profile(helpers.get_user_email()) if not profile: #if the user does not have a profile, go to home self.redirect('/') else: #otherwise, allow them to create group self.redirect("/group-edit")