comparison gpp/bio/models.py @ 54:e249b5f9d180

#3, #4: clear caches when saving profile, bulletins, and news. Broke up the stuff on the home page for finer control of caching.
author Brian Neal <bgneal@gmail.com>
date Tue, 23 Jun 2009 00:11:00 +0000
parents 5eed5e7c1c98
children c0d3b09c9b95
comparison
equal deleted inserted replaced
53:f882ac8ce255 54:e249b5f9d180
7 7
8 from django.db import models 8 from django.db import models
9 from django.contrib import auth 9 from django.contrib import auth
10 from django.conf import settings 10 from django.conf import settings
11 from django.template.loader import render_to_string 11 from django.template.loader import render_to_string
12 from django.core.cache import cache
12 13
13 14
14 def avatar_file_path_for_user(username, filename): 15 def avatar_file_path_for_user(username, filename):
15 return os.path.join(settings.AVATAR_DIR, 'users', username, filename) 16 return os.path.join(settings.AVATAR_DIR, 'users', username, filename)
16 17
44 html = render_to_string('bio/markdown.html', {'data': self.profile_text}) 45 html = render_to_string('bio/markdown.html', {'data': self.profile_text})
45 self.profile_html = html.strip() 46 self.profile_html = html.strip()
46 html = render_to_string('bio/markdown.html', {'data': self.signature}) 47 html = render_to_string('bio/markdown.html', {'data': self.signature})
47 self.signature_html = html.strip() 48 self.signature_html = html.strip()
48 super(UserProfile, self).save(*args, **kwargs) 49 super(UserProfile, self).save(*args, **kwargs)
50 cache.delete('avatar_' + self.user.username)
49 51