def test_delete_signup(self): signup_models.create_or_update_signup('*****@*****.**', { 'q1': 'a1', 'q2': 'a2', 'q3': 'a3' }) signup_models.create_or_update_signup('*****@*****.**', { 'q1': 'ar1', 'q2': 'ar2' }) signup_models.create_or_update_signup('*****@*****.**', { 'q1': 'ar1', 'q2': 'ar2' }) signup_models.create_or_update_signup('*****@*****.**', { 'q1': 'ar1', 'q2': 'ar2' }) signup_models.create_or_update_signup('*****@*****.**', { 'q1': 'ar1', 'q2': 'ar2' }) self.assertEqual(len(signup_models.get_signups()), 4) new_signups = signup_models.get_new_signups() self.assertIn('*****@*****.**', [s['email'] for s in new_signups]) signup_models.delete_signup('*****@*****.**') signups = signup_models.get_signups() self.assertEqual(len(signups), 3) self.assertNotIn('*****@*****.**', [s['email'] for s in signups]) new_signups = signup_models.get_new_signups() self.assertNotIn('*****@*****.**', [s['email'] for s in new_signups]) signup_models.create_or_update_signup('*****@*****.**', { 'q1': 'ar1', 'q2': 'ar2' }) self.assertEqual(len(signup_models.get_signups()), 4) new_signups = signup_models.get_new_signups() self.assertIn('*****@*****.**', [s['email'] for s in new_signups])
def unsubscribe_user( address ): """ Unsubscribe user completely from the Mechanical Mooc """ # remove from sequence group try: user_signup = signup_model.get_signup(address) sequence_list = sequence_model.sequence_list_name(user_signup['sequence']) mailgun_api.remove_list_member(sequence_list, address) except: log.error(u"couldn't remove {0} from sequence list".format(address)) # remove from small groups groups = groups_model.get_member_groups(address) for group in groups: groups_model.remove_group_member(group['uri'], address) groups_model.sync_group_with_mailgun(group['uri']) # mark as unsubscribed in the signups signup_model.delete_signup(address)
def unsubscribe_user(address): """ Unsubscribe user completely from the Mechanical Mooc - all sequences """ # remove from sequence group signups = signup_model.get_all_user_signups(address) for user_signup in signups: sequence_list = sequence_model.sequence_list_name(user_signup["sequence"]) mailgun_api.remove_list_member(sequence_list, address) # remove from small groups groups = groups_model.get_member_groups(address) for group in groups: groups_model.remove_group_member(group["uri"], address) groups_model.sync_group_with_mailgun(group["uri"]) # mark as unsubscribed in the signups for user_signup in signups: signup_model.delete_signup(address, user_signup["sequence"]) mailgun_api.delete_all_unsubscribes(address)
def unsubscribe_user(address): """ Unsubscribe user completely from the Mechanical Mooc - all sequences """ # remove from sequence group signups = signup_model.get_all_user_signups(address) for user_signup in signups: sequence_list = sequence_model.sequence_list_name( user_signup['sequence']) mailgun_api.remove_list_member(sequence_list, address) # remove from small groups groups = groups_model.get_member_groups(address) for group in groups: groups_model.remove_group_member(group['uri'], address) groups_model.sync_group_with_mailgun(group['uri']) # mark as unsubscribed in the signups for user_signup in signups: signup_model.delete_signup(address, user_signup['sequence']) mailgun_api.delete_all_unsubscribes(address)
def test_delete_signup(self): signup_models.create_or_update_signup('*****@*****.**', {'q1':'a1', 'q2':'a2', 'q3':'a3'}) signup_models.create_or_update_signup('*****@*****.**', {'q1':'ar1', 'q2':'ar2'}) signup_models.create_or_update_signup('*****@*****.**', {'q1':'ar1', 'q2':'ar2'}) signup_models.create_or_update_signup('*****@*****.**', {'q1':'ar1', 'q2':'ar2'}) signup_models.create_or_update_signup('*****@*****.**', {'q1':'ar1', 'q2':'ar2'}) self.assertEqual(len(signup_models.get_signups(1)), 4) new_signups = signup_models.get_new_signups() self.assertIn('*****@*****.**', [s['email'] for s in new_signups]) signup_models.delete_signup('*****@*****.**', 1) signups = signup_models.get_signups(1) self.assertEqual(len(signups), 3) self.assertNotIn('*****@*****.**', [s['email'] for s in signups]) new_signups = signup_models.get_new_signups() self.assertNotIn('*****@*****.**', [s['email'] for s in new_signups]) signup_models.create_or_update_signup('*****@*****.**', {'q1':'ar1', 'q2':'ar2'}) self.assertEqual(len(signup_models.get_signups(1)), 4) new_signups = signup_models.get_new_signups() self.assertIn('*****@*****.**', [s['email'] for s in new_signups])