Mercurial > public > sg101
comparison gpp/forums/attachments.py @ 286:72fd300685d5
For #95. You can now make posts with no text in the body if you have attachments. And now if you create a new topic with an attachment, and the POST fails (say you forgot the topic title), we will now re-attach attachments. Also fixed a bug in the smiley code that would arise if it was asked to markup an empty string.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 23 Oct 2010 20:19:46 +0000 |
parents | 8fd4984d5c3b |
children |
comparison
equal
deleted
inserted
replaced
285:8fd4984d5c3b | 286:72fd300685d5 |
---|---|
15 def __init__(self, ids): | 15 def __init__(self, ids): |
16 """ | 16 """ |
17 This class is constructed with a list of Oembed ids. We retrieve the | 17 This class is constructed with a list of Oembed ids. We retrieve the |
18 actual Oembed objects associated with these keys for use in subsequent | 18 actual Oembed objects associated with these keys for use in subsequent |
19 operations. | 19 operations. |
20 | 20 |
21 """ | 21 """ |
22 # ensure all ids are integers | 22 # ensure all ids are integers |
23 self.pks = [] | 23 self.pks = [] |
24 for pk in ids: | 24 for pk in ids: |
25 try: | 25 try: |
41 post.attachments.clear() | 41 post.attachments.clear() |
42 | 42 |
43 for n, pk in enumerate(self.pks): | 43 for n, pk in enumerate(self.pks): |
44 attachment = Attachment(post=post, embed=self.embeds[pk], order=n) | 44 attachment = Attachment(post=post, embed=self.embeds[pk], order=n) |
45 attachment.save() | 45 attachment.save() |
46 | |
47 def has_attachments(self): | |
48 """ | |
49 Return true if we have valid pending attachments. | |
50 | |
51 """ | |
52 return len(self.embeds) > 0 | |
53 | |
54 def get_ids(self): | |
55 """ | |
56 Return the list of Oembed ids. | |
57 | |
58 """ | |
59 return self.pks |