Show More
@@ -8,7 +8,6 b' class PostForm(forms.Form):' | |||||
8 | title = forms.CharField(max_length=50, required=False) |
|
8 | title = forms.CharField(max_length=50, required=False) | |
9 | text = forms.CharField(widget=forms.Textarea, required=False) |
|
9 | text = forms.CharField(widget=forms.Textarea, required=False) | |
10 | image = forms.ImageField(required=False) |
|
10 | image = forms.ImageField(required=False) | |
11 | tags = forms.CharField(max_length=100, required=False) |
|
|||
12 |
|
11 | |||
13 | def clean_text(self): |
|
12 | def clean_text(self): | |
14 | text = self.cleaned_data['text'] |
|
13 | text = self.cleaned_data['text'] | |
@@ -38,4 +37,17 b' class PostForm(forms.Form):' | |||||
38 |
|
37 | |||
39 |
|
38 | |||
40 | class ThreadForm(PostForm): |
|
39 | class ThreadForm(PostForm): | |
41 | tags = forms.CharField(max_length=100) No newline at end of file |
|
40 | tags = forms.CharField(max_length=100) | |
|
41 | ||||
|
42 | def clean_tags(self): | |||
|
43 | tags = self.cleaned_data['tags'] | |||
|
44 | if tags: | |||
|
45 | if ('+' in tags) or ('/' in tags): | |||
|
46 | raise forms.ValidationError('Inappropriate characters in tags') | |||
|
47 | ||||
|
48 | return tags | |||
|
49 | ||||
|
50 | def clean(self): | |||
|
51 | cleaned_data = super(ThreadForm, self).clean() | |||
|
52 | ||||
|
53 | return cleaned_data No newline at end of file |
@@ -1,4 +1,5 b'' | |||||
1 | import os |
|
1 | import os | |
|
2 | import re | |||
2 | from django.db import models |
|
3 | from django.db import models | |
3 | from django.utils import timezone |
|
4 | from django.utils import timezone | |
4 | import time |
|
5 | import time | |
@@ -112,6 +113,9 b' class Tag(models.Model):' | |||||
112 | # TODO Connect the tag to its posts to check the number of threads for |
|
113 | # TODO Connect the tag to its posts to check the number of threads for | |
113 | # the tag. |
|
114 | # the tag. | |
114 |
|
115 | |||
|
116 | def __unicode__(self): | |||
|
117 | return self.name | |||
|
118 | ||||
115 |
|
119 | |||
116 | class Post(models.Model): |
|
120 | class Post(models.Model): | |
117 | """A post is a message.""" |
|
121 | """A post is a message.""" | |
@@ -160,6 +164,15 b' class Post(models.Model):' | |||||
160 | # TODO Make a better algorithm for describing gets |
|
164 | # TODO Make a better algorithm for describing gets | |
161 | return self.id == 1 or self.id % 10 == 0 |
|
165 | return self.id == 1 or self.id % 10 == 0 | |
162 |
|
166 | |||
|
167 | def get_parsed_text(self): | |||
|
168 | text = self.text | |||
|
169 | ||||
|
170 | # TODO Implement parsing | |||
|
171 | # Make //text colored | |||
|
172 | # Make >>12 links to posts | |||
|
173 | ||||
|
174 | return text | |||
|
175 | ||||
163 |
|
176 | |||
164 | class Admin(models.Model): |
|
177 | class Admin(models.Model): | |
165 | """ |
|
178 | """ |
@@ -1,5 +1,5 b'' | |||||
1 | html { |
|
1 | html { | |
2 |
background: # |
|
2 | background: #555; | |
3 | color: #ffffff; |
|
3 | color: #ffffff; | |
4 | } |
|
4 | } | |
5 |
|
5 | |||
@@ -71,9 +71,10 b' html {' | |||||
71 | } |
|
71 | } | |
72 |
|
72 | |||
73 | .metadata { |
|
73 | .metadata { | |
74 | background: #666; |
|
|||
75 | padding: 10px; |
|
|||
76 | border-radius: 5px; |
|
|||
77 | float: left; |
|
74 | float: left; | |
78 |
|
|
75 | padding: 2px; | |
|
76 | margin-top: 10px; | |||
|
77 | border: solid 1px #666; | |||
|
78 | font-size: 0.9em; | |||
|
79 | color: #ddd | |||
79 | } No newline at end of file |
|
80 | } |
@@ -50,7 +50,7 b' def new_post(request, thread_id=boards.m' | |||||
50 | tag_strings = data['tags'] |
|
50 | tag_strings = data['tags'] | |
51 |
|
51 | |||
52 | if tag_strings: |
|
52 | if tag_strings: | |
53 |
tag_strings = tag_strings.split(' |
|
53 | tag_strings = tag_strings.split(' ') | |
54 | for tag_name in tag_strings: |
|
54 | for tag_name in tag_strings: | |
55 | tag_name = tag_name.strip() |
|
55 | tag_name = tag_name.strip() | |
56 | if len(tag_name) > 0: |
|
56 | if len(tag_name) > 0: |
@@ -1,7 +1,10 b'' | |||||
|
1 | {% load staticfiles %} | |||
|
2 | ||||
1 | <!DOCTYPE html> |
|
3 | <!DOCTYPE html> | |
2 | <html> |
|
4 | <html> | |
3 | <head> |
|
5 | <head> | |
4 |
<link rel="stylesheet" type="text/css" |
|
6 | <link rel="stylesheet" type="text/css" | |
|
7 | href="{% static "css/base_page.css" %}" media="all"/> | |||
5 | {% block head %}{% endblock %} |
|
8 | {% block head %}{% endblock %} | |
6 | </head> |
|
9 | </head> | |
7 | <body> |
|
10 | <body> |
@@ -18,17 +18,19 b'' | |||||
18 | <span class="title">{{ thread.title }}</span> |
|
18 | <span class="title">{{ thread.title }}</span> | |
19 | <span class="post_id">(#{{ thread.id }})</span> |
|
19 | <span class="post_id">(#{{ thread.id }})</span> | |
20 | [{{ thread.pub_time }}] |
|
20 | [{{ thread.pub_time }}] | |
21 |
[<a class="link" href=" |
|
21 | [<a class="link" href="{% url 'thread' thread.id %}" | |
22 | {{ thread.text|truncatechars:300 }}<br /> |
|
22 | >{% trans "View" %}</a>]<br /> | |
|
23 | {{ thread.get_parsed_text|linebreaksbr|truncatechars:300 }}<br | |||
|
24 | /> | |||
23 | <div class="metadata"> |
|
25 | <div class="metadata"> | |
24 |
|
|
26 | {{ thread.get_reply_count }} {% trans 'replies' %}, | |
25 | {{ thread.get_images_count }} {% trans 'images' %}, |
|
27 | {{ thread.get_images_count }} {% trans 'images' %}, | |
26 |
{{ thread.get_gets_count }} {% trans 'gets' %} |
|
28 | {{ thread.get_gets_count }} {% trans 'gets' %}. | |
27 | <br /> |
|
|||
28 | {% if thread.tags.all %} |
|
29 | {% if thread.tags.all %} | |
29 | <span class="tags">{% trans 'Tags' %}: |
|
30 | <span class="tags">{% trans 'Tags' %}: | |
30 | {% for tag in thread.tags.all %} |
|
31 | {% for tag in thread.tags.all %} | |
31 |
<a class="tag" href=" |
|
32 | <a class="tag" href=" | |
|
33 | {% url 'tag' tag_name=tag.name %}"> | |||
32 | {{ tag.name }}</a> |
|
34 | {{ tag.name }}</a> | |
33 | {% endfor %} |
|
35 | {% endfor %} | |
34 | </span> |
|
36 | </span> | |
@@ -62,6 +64,8 b'' | |||||
62 | <div class="form-input">{{ form.tags }}</div> |
|
64 | <div class="form-input">{{ form.tags }}</div> | |
63 | </div> |
|
65 | </div> | |
64 | <input type="submit" value="{% trans 'Post' %}" /> |
|
66 | <input type="submit" value="{% trans 'Post' %}" /> | |
|
67 | <hr /> | |||
|
68 | {% trans "Tags must be delimited by spaces. Text or image is required." %} | |||
65 | </form> |
|
69 | </form> | |
66 | </div> |
|
70 | </div> | |
67 |
|
71 |
@@ -20,12 +20,12 b'' | |||||
20 | <a class="post_id" href="#{{ post.id }}"> |
|
20 | <a class="post_id" href="#{{ post.id }}"> | |
21 | (#{{ post.id }})</a> |
|
21 | (#{{ post.id }})</a> | |
22 | [{{ post.pub_time }}]<br /> |
|
22 | [{{ post.pub_time }}]<br /> | |
23 | {{ post.text }}<br /> |
|
23 | {{ post.get_parsed_text|linebreaksbr }}<br /> | |
24 | {% if post.tags.all %} |
|
24 | {% if post.tags.all %} | |
25 | <div class="metadata"> |
|
25 | <div class="metadata"> | |
26 | <span class="tags">{% trans 'Tags' %}: |
|
26 | <span class="tags">{% trans 'Tags' %}: | |
27 | {% for tag in post.tags.all %} |
|
27 | {% for tag in post.tags.all %} | |
28 |
<a class="tag" href=" |
|
28 | <a class="tag" href="{% url 'tag' tag.name %}"> | |
29 | {{ tag.name }}</a> |
|
29 | {{ tag.name }}</a> | |
30 | {% endfor %} |
|
30 | {% endfor %} | |
31 | </span> |
|
31 | </span> |
General Comments 0
You need to be logged in to leave comments.
Login now