img_temp = NamedTemporaryFile(delete=True) img_temp.write(urllib2.urlopen(url).read()) img_temp.flush() try: a = user.avatar_set.get() except: a = user.avatar_set.model(user=user) a.avatar.save(name, File(img_temp)) user.avatar_set.add(a) def audit_user(backend, details, response, social_user, uid,\ user, *args, **kwargs): user.get_profile().update_audit() register_save_handler(ContactDetail, create_verb='joined MapStory', provide_user=False, check_publish=False) register_save_handler(Layer, create_verb='uploaded') register_save_handler(Map) map_changed_signal.connect(map_handler) post_save.connect(publishing_handler, sender=PublishingStatus) post_save.connect(rating_handler, sender=Rating) post_save.connect(comment_handler, sender=Comment) m2m_changed.connect(notify_handler, sender=UserActivity.other_actor_actions.through) content_flagged.connect(flag_handler)
class SpatialTemporalIndex(models.Model): time_start = models.BigIntegerField(null=True) time_end = models.BigIntegerField(null=True) extent = models.PolygonField() objects = models.GeoManager() class Meta: abstract = True def __unicode__(self): return '<SpatialTemporalIndex> for %s, %s, %s - %s' % ( self.indexed, self.extent.extent, util.jdate_to_approx_iso_str(self.time_start), util.jdate_to_approx_iso_str(self.time_end)) class LayerIndex(SpatialTemporalIndex): indexed = models.OneToOneField(Layer, related_name='spatial_temporal_index') class MapIndex(SpatialTemporalIndex): indexed = models.OneToOneField(Map, related_name='spatial_temporal_index') signals.post_save.connect(object_created, sender=Layer) signals.pre_delete.connect(object_deleted, sender=Map) signals.pre_delete.connect(object_deleted, sender=Layer) map_changed_signal.connect(map_updated)
action(what.owner, 'published', action_object=what) layers = getattr(what, 'local_layers', []) for l in layers: if l.owner != what.owner: # make this hidden so it doesn't show up act = action(what.owner, verb='published', action_object=l, target=what, public=False) # except here l.owner.useractivity.other_actor_actions.add(act) def map_handler(sender, what_changed, old, new, **kw): if what_changed == 'layers' and sender.publish.status == 'Public': added = old ^ new layers = Layer.objects.filter(typename__in=added) for l in layers: act = action(sender.owner, verb='added', action_object=l, target=sender) # if the layer owner is not the map owner, tell the layer owner if l.owner != sender.owner: l.owner.useractivity.other_actor_actions.add(act) register_save_handler(ContactDetail, create_verb='joined MapStory', provide_user=False) register_save_handler(Layer, create_verb='uploaded') register_save_handler(Map) map_changed_signal.connect(map_handler) post_save.connect(publishing_handler, sender=PublishingStatus) post_save.connect(rating_handler, sender=Rating) post_save.connect(comment_handler, sender=Comment) m2m_changed.connect(notify_handler, sender=UserActivity.other_actor_actions.through)
from django.contrib.gis.gdal import Envelope class SpatialTemporalIndex(models.Model): time_start = models.BigIntegerField(null=True) time_end = models.BigIntegerField(null=True) extent = models.PolygonField() objects = models.GeoManager() class Meta: abstract = True def __unicode__(self): return '<SpatialTemporalIndex> for %s, %s, %s - %s' % ( self.indexed, self.extent.extent, util.jdate_to_approx_iso_str(self.time_start), util.jdate_to_approx_iso_str(self.time_end) ) class LayerIndex(SpatialTemporalIndex): indexed = models.OneToOneField(Layer,related_name='spatial_temporal_index') class MapIndex(SpatialTemporalIndex): indexed = models.OneToOneField(Map,related_name='spatial_temporal_index') signals.post_save.connect(object_created, sender=Layer) signals.pre_delete.connect(object_deleted, sender=Map) signals.pre_delete.connect(object_deleted, sender=Layer) map_changed_signal.connect(map_updated)