def save(self, *args, **kwargs): """ Creates a new ``Checkin`` for a user. This can be done for anonymous users or for real users. Since we call ``checkin.save()`` here, the ``save()`` override will take care of expiring older checkins for the given user. """ self.pre_save(*args, **kwargs) checkin = Checkin() checkin.place = self.place if self.user: checkin.user = self.user else: checkin.user_name = self.cleaned_data['user_name'] checkin.point = Point( self.cleaned_data['lng'], self.cleaned_data['lat'], ) checkin.save() from matchmaker import facebook if (self.cleaned_data.get('access_token') and self.cleaned_data.get('post_to_facebook')): graph = facebook.GraphAPI(self.cleaned_data.get('access_token')) graph.put_wall_post( "I'm playing basketball now at {0}." ' Come and join me: {1}{2}'.format( self.place, settings.HOSTNAME, self.place.get_absolute_url() )) return checkin
def save(self, *args, **kwargs): """ Creates a new ``Checkin`` for a user. This can be done for anonymous users or for real users. Since we call ``checkin.save()`` here, the ``save()`` override will take care of expiring older checkins for the given user. """ self.pre_save(*args, **kwargs) checkin = Checkin() checkin.place = self.place if self.user: checkin.user = self.user else: checkin.user_name = self.cleaned_data['user_name'] checkin.point = Point( self.cleaned_data['lng'], self.cleaned_data['lat'], ) checkin.save() from matchmaker import facebook if (self.cleaned_data.get('access_token') and self.cleaned_data.get('post_to_facebook')): graph = facebook.GraphAPI(self.cleaned_data.get('access_token')) graph.put_wall_post("I'm playing basketball now at {0}." ' Come and join me: {1}{2}'.format( self.place, settings.HOSTNAME, self.place.get_absolute_url())) return checkin
def save(self, *args, **kwargs): """ Creates a number of new checkins for anonymous users. Users will be called ``User1``, ``User2`` and so on. """ self.pre_save(*args, **kwargs) highest_number = self._get_highest_user_name() count = self.cleaned_data.get('count') for i in range(highest_number + 1, highest_number + 1 + count, 1): checkin = Checkin() checkin.place = self.place checkin.user_name = '{0}{1}'.format(self.user_name_base, i) checkin.point = Point( self.cleaned_data['lng'], self.cleaned_data['lat'], ) checkin.save() return checkin