def unfollow(self): follower = self.session.auth.user if self.session.auth else None try: followed = self.db.auth_user[int(self.request.args(0))] except: followed = self.db(self.db.auth_user.nickname == self.request.args(0)).select(0).first() yourself = followed.id == follower.id if follower and followed: if not yourself: relation = self.db.UserContact._relation(follower.id, followed.id) query = (self.db.UserContact.follower == follower.id) & (self.db.UserContact.followed == followed.id) self.db(query).delete() self.db.commit() if relation == 'contacts': acount = followed.contacts - 1 followed.update_record(contacts=acount) follower_user = self.db.auth_user[int(follower.id)] bcount = follower_user.contacts - 1 follower_user.update_record(contacts=bcount) return contact_box(followed, 'follower', ajax=True) else: return self.T('You cannot unfollow yourself') else: return self.T('Error unfollowing')
def unfollow(self): follower = self.session.auth.user if self.session.auth else None try: followed = self.db.auth_user[int(self.request.args(0))] except: followed = self.db(self.db.auth_user.nickname == self.request.args(0)).select(0).first() yourself = followed.id == follower.id if follower and followed: if not yourself: #relation = self.db.UserContact._relation(follower.id, followed.id) query = (self.db.UserContact.follower == follower.id) & (self.db.UserContact.followed == followed.id) self.db(query).delete() self.db.commit() # if relation == 'contacts': # acount = followed.contacts - 1 # followed.update_record(contacts=acount) # follower_user = self.db.auth_user[int(follower.id)] # bcount = follower_user.contacts - 1 # follower_user.update_record(contacts=bcount) self.update_contact_counter(follower, followed) return contact_box(followed, 'follower', ajax=True, css={"main": "well span5", "img": "span", "div": "four columns"}) else: return self.T('You cannot unfollow yourself') else: return self.T('Error unfollowing')
def follow(self): follower = self.session.auth.user if self.session.auth else None if not follower and 'profile' in self.request.args: return "window.location = '%s'" % self.CURL( 'default', 'user', args='login', vars={ '_next': self.CURL( 'person', 'show', args=self.request.args(0)) }) try: followed = self.db.auth_user[int(self.request.args(0))] except: followed = self.db(self.db.auth_user.nickname == self.request.args( 0)).select(0).first() yourself = followed.id == follower.id if follower and followed: if not yourself: self.db.UserContact.update_or_insert(follower=follower.id, followed=followed.id) self.db.commit() self.db.UserTimeLine._new_event( v={ "user_id": follower.id, "nickname": follower.nickname, "event_type": "new_contact", "event_image": self.get_image(None, 'user', themename=self.context.theme_name, user=follower), "event_to": followed.nickname or followed.first_name, "event_reference": followed.id, "event_text": "", "event_link": followed.nickname or followed.id }) relation = self.db.UserContact._relation( follower.id, followed.id) if relation == 'contacts': acount = followed.contacts + 1 followed.update_record(contacts=acount) follower_user = self.db.auth_user[int(follower.id)] bcount = follower_user.contacts + 1 follower_user.update_record(contacts=bcount) return contact_box(followed, 'contact', ajax=True) else: return self.T('You cannot follow yourself') else: return self.T('Error following')
def unfollow(self): follower = self.session.auth.user if self.session.auth else None try: followed = self.db.auth_user[int(self.request.args(0))] except: followed = self.db(self.db.auth_user.nickname == self.request.args( 0)).select(0).first() yourself = followed.id == follower.id if follower and followed: if not yourself: relation = self.db.UserContact._relation( follower.id, followed.id) query = (self.db.UserContact.follower == follower.id) & ( self.db.UserContact.followed == followed.id) self.db(query).delete() self.db.commit() if relation == 'contacts': acount = followed.contacts - 1 followed.update_record(contacts=acount) follower_user = self.db.auth_user[int(follower.id)] bcount = follower_user.contacts - 1 follower_user.update_record(contacts=bcount) return contact_box(followed, 'follower', ajax=True) else: return self.T('You cannot unfollow yourself') else: return self.T('Error unfollowing')
def follow(self): follower = self.session.auth.user if self.session.auth else None if not follower and 'profile' in self.request.args: return "window.location = '%s'" % self.CURL('default', 'user', args='login', vars={'_next': self.CURL('person', 'show', args=self.request.args(0))}) try: followed = self.db.auth_user[int(self.request.args(0))] except: followed = self.db(self.db.auth_user.nickname == self.request.args(0)).select(0).first() yourself = followed.id == follower.id if follower and followed: if not yourself: self.db.UserContact.update_or_insert(follower=follower.id, followed=followed.id) self.db.commit() self.db.UserTimeLine._new_event(v={"user_id": follower.id, "nickname": follower.nickname, "event_type": "new_contact", "event_image": self.get_image(None, 'user', themename=self.context.theme_name, user=follower), "event_to": followed.nickname or followed.first_name, "event_reference": followed.id, "event_text": "", "event_link": follower.nickname or follower.id, "event_link_to": followed.nickname or followed.id, "event_image_to": self.get_image(None, 'user', themename=self.context.theme_name, user=followed)}) # self.mail.send(to=followed.email, # subject=self.T("Hi, %(nickname)s followed you on Movuca", follower), # message=[None, """<h1>You got a new follower!</h1><p>%(nickname)s is now following you, follow back!</p>Note: this is a beta test of http://movu.ca CMS, thank you for the help with tests""" % follower]) # # TODO: RENDER TEMPLATE EMAILS CHECK PREFERENCES FOR NOTIFICATIONS self.notifier.notify("new_contact", followed, event_text=self.T("%(nickname)s followed you", follower), event_link=follower.nickname or follower.id, event_reference=followed.id, event_image=self.get_image(None, 'user', themename=self.context.theme_name, user=follower), follower=follower ) relation = self.db.UserContact._relation(follower.id, followed.id) if relation == 'contacts': acount = followed.contacts + 1 followed.update_record(contacts=acount) follower_user = self.db.auth_user[int(follower.id)] bcount = follower_user.contacts + 1 follower_user.update_record(contacts=bcount) return contact_box(followed, 'contact', ajax=True) else: return self.T('You cannot follow yourself') else: return self.T('Error following')
def follow(self): follower = self.session.auth.user if self.session.auth else None if not follower and 'profile' in self.request.args: return "window.location = '%s'" % self.CURL('default', 'user', args='login', vars={'_next': self.CURL('person', 'show', args=self.request.args(0))}) try: followed = self.db.auth_user[int(self.request.args(0))] except: followed = self.db(self.db.auth_user.nickname == self.request.args(0)).select(0).first() yourself = followed.id == follower.id if follower and followed: if not yourself: self.db.UserContact.update_or_insert(follower=follower.id, followed=followed.id) self.db.commit() self.db.UserTimeLine._new_event(v={"user_id": follower.id, "nickname": follower.nickname, "event_type": "new_contact", "event_image": self.get_image(None, 'user', themename=self.context.theme_name, user=follower), "event_to": followed.nickname or followed.first_name, "event_reference": followed.id, "event_text": "", "event_link": follower.nickname or follower.id, "event_link_to": followed.nickname or followed.id, "event_image_to": self.get_image(None, 'user', themename=self.context.theme_name, user=followed)}) self.notifier.notify("new_contact", followed, event_text=self.T("%(nickname)s followed you", follower), event_link=follower.nickname or follower.id, event_reference=followed.id, event_image=self.get_image(None, 'user', themename=self.context.theme_name, user=follower), follower=follower ) # relation = self.db.UserContact._relation(follower.id, followed.id) # if relation == 'contacts': # acount = followed.contacts + 1 # followed.update_record(contacts=acount) # follower_user = self.db.auth_user[int(follower.id)] # bcount = follower_user.contacts + 1 # follower_user.update_record(contacts=bcount) self.update_contact_counter(follower, followed) return contact_box(followed, 'contact', ajax=True, css={"main": "well span5", "img": "span", "div": "four columns"}) else: return self.T('You cannot follow yourself') else: return self.T('Error following')
def follow(self): follower = self.session.auth.user if self.session.auth else None if not follower and 'profile' in self.request.args: return "window.location = '%s'" % self.CURL('default', 'user', args='login', vars={'_next': self.CURL('person', 'show', args=self.request.args(0))}) try: followed = self.db.auth_user[int(self.request.args(0))] except: followed = self.db(self.db.auth_user.nickname == self.request.args(0)).select(0).first() yourself = followed.id == follower.id if follower and followed: if not yourself: self.db.UserContact.update_or_insert(follower=follower.id, followed=followed.id) self.db.commit() self.db.UserTimeLine._new_event(v={"user_id": follower.id, "nickname": follower.nickname, "event_type": "new_contact", "event_image": self.get_image(None, 'user', themename=self.context.theme_name, user=follower), "event_to": followed.nickname or followed.first_name, "event_reference": followed.id, "event_text": "", "event_link": followed.nickname or followed.id}) relation = self.db.UserContact._relation(follower.id, followed.id) if relation == 'contacts': acount = followed.contacts + 1 followed.update_record(contacts=acount) follower_user = self.db.auth_user[int(follower.id)] bcount = follower_user.contacts + 1 follower_user.update_record(contacts=bcount) return contact_box(followed, 'contact', ajax=True) else: return self.T('You cannot follow yourself') else: return self.T('Error following')
def unfollow(self): follower = self.session.auth.user if self.session.auth else None try: followed = self.db.auth_user[int(self.request.args(0))] except: followed = self.db(self.db.auth_user.nickname == self.request.args( 0)).select(0).first() yourself = followed.id == follower.id if follower and followed: if not yourself: #relation = self.db.UserContact._relation(follower.id, followed.id) query = (self.db.UserContact.follower == follower.id) & ( self.db.UserContact.followed == followed.id) self.db(query).delete() self.db.commit() # if relation == 'contacts': # acount = followed.contacts - 1 # followed.update_record(contacts=acount) # follower_user = self.db.auth_user[int(follower.id)] # bcount = follower_user.contacts - 1 # follower_user.update_record(contacts=bcount) self.update_contact_counter(follower, followed) return contact_box(followed, 'follower', ajax=True, css={ "main": "well span5", "img": "span", "div": "four columns" }) else: return self.T('You cannot unfollow yourself') else: return self.T('Error unfollowing')
def follow(self): follower = self.session.auth.user if self.session.auth else None if not follower and 'profile' in self.request.args: return "window.location = '%s'" % self.CURL( 'default', 'user', args='login', vars={ '_next': self.CURL( 'person', 'show', args=self.request.args(0)) }) try: followed = self.db.auth_user[int(self.request.args(0))] except: followed = self.db(self.db.auth_user.nickname == self.request.args( 0)).select(0).first() yourself = followed.id == follower.id if follower and followed: if not yourself: self.db.UserContact.update_or_insert(follower=follower.id, followed=followed.id) self.db.commit() self.db.UserTimeLine._new_event( v={ "user_id": follower.id, "nickname": follower.nickname, "event_type": "new_contact", "event_image": self.get_image(None, 'user', themename=self.context.theme_name, user=follower), "event_to": followed.nickname or followed.first_name, "event_reference": followed.id, "event_text": "", "event_link": follower.nickname or follower.id, "event_link_to": followed.nickname or followed.id, "event_image_to": self.get_image(None, 'user', themename=self.context.theme_name, user=followed) }) self.notifier.notify( "new_contact", followed, event_text=self.T("%(nickname)s followed you", follower), event_link=follower.nickname or follower.id, event_reference=followed.id, event_image=self.get_image( None, 'user', themename=self.context.theme_name, user=follower), follower=follower) # relation = self.db.UserContact._relation(follower.id, followed.id) # if relation == 'contacts': # acount = followed.contacts + 1 # followed.update_record(contacts=acount) # follower_user = self.db.auth_user[int(follower.id)] # bcount = follower_user.contacts + 1 # follower_user.update_record(contacts=bcount) self.update_contact_counter(follower, followed) return contact_box(followed, 'contact', ajax=True, css={ "main": "well span5", "img": "span", "div": "four columns" }) else: return self.T('You cannot follow yourself') else: return self.T('Error following')