Merge lp:~daker/loco-team-portal/fix.planet-1 into lp:loco-team-portal

Proposed by Adnane Belmadiaf on 2012-12-12
Status: Merged
Approved by: Adnane Belmadiaf on 2012-12-13
Approved revision: 582
Merged at revision: 578
Proposed branch: lp:~daker/loco-team-portal/fix.planet-1
Merge into: lp:loco-team-portal
Diff against target: 297 lines (+168/-22)
4 files modified
Vagrantfile (+1/-6)
loco_directory/articles/migrations/0002_auto__del_field_article_snippet__add_field_article_content.py (+153/-0)
loco_directory/articles/models.py (+4/-6)
loco_directory/templates/index.html (+10/-10)
To merge this branch: bzr merge lp:~daker/loco-team-portal/fix.planet-1
Reviewer Review Type Date Requested Status
LoCo Team Portal Developers 2012-12-12 Pending
Review via email: mp+139585@code.launchpad.net

Commit Message

Change the feed importer to include the whole article with html

Description of the Change

To post a comment you must log in.
579. By Adnane Belmadiaf on 2012-12-12

Added striptags to remove unwanted content

580. By Adnane Belmadiaf on 2012-12-12

Reverted back refresh command

581. By Adnane Belmadiaf on 2012-12-12

Reverted the default value of last_updated field

582. By Adnane Belmadiaf on 2012-12-12

Fix var name

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Vagrantfile'
2--- Vagrantfile 2012-11-26 00:02:28 +0000
3+++ Vagrantfile 2012-12-12 23:09:21 +0000
4@@ -3,9 +3,6 @@
5
6 Vagrant::Config.run do |ltp|
7
8- #sshconf = "#{ENV['HOME']}/.ssh/"
9- #bzrconf = "#{ENV['HOME']}/.bazaar/"
10-
11 ltp.vm.box = "ltp-devserver"
12 ltp.vm.box_url = "http://files.vagrantup.com/precise32.box"
13 ltp.vm.forward_port 8000, 8000
14@@ -15,9 +12,7 @@
15 ltp.ssh.max_tries = 50
16 ltp.ssh.timeout = 300
17
18- ltp.vm.share_folder("v-root", "/home/vagrant/ltp", ".")
19- #ltp.vm.share_folder("v-ssh", "/home/vagrant/.host-ssh", sshconf)
20- #ltp.vm.share_folder("v-bzr", "/home/vagrant/.bazaar", bzrconf)
21+ ltp.vm.share_folder("v-root", "/home/vagrant/ltp", ".", :nfs => true)
22
23 ltp.vm.provision :puppet do |puppet|
24 puppet.manifests_path = "puppet/manifests"
25
26=== added file 'loco_directory/articles/migrations/0002_auto__del_field_article_snippet__add_field_article_content.py'
27--- loco_directory/articles/migrations/0002_auto__del_field_article_snippet__add_field_article_content.py 1970-01-01 00:00:00 +0000
28+++ loco_directory/articles/migrations/0002_auto__del_field_article_snippet__add_field_article_content.py 2012-12-12 23:09:21 +0000
29@@ -0,0 +1,153 @@
30+# encoding: utf-8
31+import datetime
32+from south.db import db
33+from south.v2 import SchemaMigration
34+from django.db import models
35+
36+class Migration(SchemaMigration):
37+
38+ def forwards(self, orm):
39+
40+ # Deleting field 'article.snippet'
41+ db.delete_column('articles_article', 'snippet')
42+
43+ # Adding field 'Article.content'
44+ db.add_column('articles_article', 'content', self.gf('django.db.models.fields.TextField')(null=True, blank=True), keep_default=False)
45+
46+
47+ def backwards(self, orm):
48+
49+ # Adding field 'article.snippet'
50+ db.add_column('articles_article', 'snippet', self.gf('django.db.models.fields.CharField')(max_length=512, null=True, blank=True), keep_default=False)
51+
52+ # Deleting field 'Article.content'
53+ db.delete_column('articles_article', 'content')
54+
55+
56+ models = {
57+ 'articles.article': {
58+ 'Meta': {'ordering': "['-imported', '-published']", 'object_name': 'Article'},
59+ 'author': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}),
60+ 'content': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
61+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
62+ 'imported': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
63+ 'link': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
64+ 'published': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
65+ 'source': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['articles.Feed']", 'null': 'True', 'blank': 'True'}),
66+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}),
67+ 'uid': ('django.db.models.fields.CharField', [], {'max_length': '256'})
68+ },
69+ 'articles.feed': {
70+ 'Meta': {'ordering': "('title',)", 'object_name': 'Feed'},
71+ 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
72+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
73+ 'last_updated': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(1970, 1, 1, 0, 0)'}),
74+ 'team': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['teams.Team']", 'null': 'True', 'blank': 'True'}),
75+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}),
76+ 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}),
77+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['userprofiles.UserProfile']", 'null': 'True', 'blank': 'True'})
78+ },
79+ 'auth.group': {
80+ 'Meta': {'object_name': 'Group'},
81+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
82+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
83+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
84+ },
85+ 'auth.permission': {
86+ 'Meta': {'ordering': "('content_type__app_label', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
87+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
88+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
89+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
90+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
91+ },
92+ 'auth.user': {
93+ 'Meta': {'object_name': 'User'},
94+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
95+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
96+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
97+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
98+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
99+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
100+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
101+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
102+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
103+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
104+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
105+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
106+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
107+ },
108+ 'contenttypes.contenttype': {
109+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
110+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
111+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
112+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
113+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
114+ },
115+ 'teams.continent': {
116+ 'Meta': {'ordering': "('name',)", 'object_name': 'Continent'},
117+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
118+ 'name': ('django.db.models.fields.TextField', [], {'max_length': '50'})
119+ },
120+ 'teams.country': {
121+ 'Meta': {'ordering': "('name',)", 'object_name': 'Country'},
122+ 'continents': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['teams.Continent']", 'symmetrical': 'False'}),
123+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
124+ 'name': ('django.db.models.fields.TextField', [], {'max_length': '100'})
125+ },
126+ 'teams.language': {
127+ 'Meta': {'ordering': "('name',)", 'object_name': 'Language'},
128+ 'code': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True'}),
129+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
130+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '150', 'null': 'True'})
131+ },
132+ 'teams.team': {
133+ 'Meta': {'ordering': "('approved', 'name')", 'object_name': 'Team', 'db_table': "'teams'"},
134+ 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
135+ 'admin_profiles': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'admins'", 'symmetrical': 'False', 'to': "orm['userprofiles.UserProfile']"}),
136+ 'approved': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
137+ 'approved_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
138+ 'city': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
139+ 'contact_profiles': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'contacts'", 'symmetrical': 'False', 'to': "orm['userprofiles.UserProfile']"}),
140+ 'countries': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['teams.Country']", 'symmetrical': 'False'}),
141+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}),
142+ 'expires_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
143+ 'flickr_id': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True', 'blank': 'True'}),
144+ 'forum_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
145+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
146+ 'irc_chan': ('django.db.models.fields.CharField', [], {'max_length': '25', 'null': 'True', 'blank': 'True'}),
147+ 'languages': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['teams.Language']", 'symmetrical': 'False'}),
148+ 'lp_name': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True'}),
149+ 'microbloghashtag': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
150+ 'ml_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
151+ 'mugshot_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
152+ 'name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '80'}),
153+ 'override_name': ('django.db.models.fields.CharField', [], {'max_length': '80', 'null': 'True', 'blank': 'True'}),
154+ 'owner_profile': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'owner'", 'null': 'True', 'to': "orm['userprofiles.UserProfile']"}),
155+ 'picasa_id': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True', 'blank': 'True'}),
156+ 'pixie_id': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True', 'blank': 'True'}),
157+ 'provides_support': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
158+ 'spr': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
159+ 'tz': ('django.db.models.fields.CharField', [], {'default': "'UTC'", 'max_length': '32'}),
160+ 'web_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
161+ 'wiki_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'})
162+ },
163+ 'userprofiles.userprofile': {
164+ 'Meta': {'ordering': "('user__username',)", 'object_name': 'UserProfile'},
165+ 'aim': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
166+ 'blog': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
167+ 'facebook': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
168+ 'flickr': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
169+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
170+ 'identica': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
171+ 'irc': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
172+ 'mugshot': ('django.db.models.fields.URLField', [], {'max_length': '150', 'null': 'True', 'blank': 'True'}),
173+ 'picasa': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
174+ 'realname': ('django.db.models.fields.CharField', [], {'max_length': '150', 'blank': 'True'}),
175+ 'twitter': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
176+ 'tz': ('django.db.models.fields.CharField', [], {'default': "'UTC'", 'max_length': '32'}),
177+ 'user': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True'}),
178+ 'xmpp': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'})
179+ }
180+ }
181+
182+ complete_apps = ['articles']
183
184=== modified file 'loco_directory/articles/models.py'
185--- loco_directory/articles/models.py 2012-06-01 22:28:09 +0000
186+++ loco_directory/articles/models.py 2012-12-12 23:09:21 +0000
187@@ -6,7 +6,6 @@
188 import urllib2
189
190 from django.db import models
191-from django.utils.html import strip_tags
192 from django.conf import settings
193
194 from teams.models import Team
195@@ -62,7 +61,6 @@
196 if not data or not hasattr(data, 'entries') or len(data.entries) == 0:
197 # No new entries for this feed
198 return
199-
200 now = datetime.datetime.now()
201 existing_articles = set(list(Article.objects.filter(source=self).values_list('uid', flat=True)))
202 returned_articles = set([])
203@@ -86,9 +84,9 @@
204 imp_date = now
205
206 if hasattr(entry, 'content'):
207- snippet = entry.content[0].value
208+ content = entry.content[0].value
209 else:
210- snippet = entry.get('description', '')
211+ content = entry.get('description', '')
212
213 article = Article(
214 source=self,
215@@ -98,7 +96,7 @@
216 imported=imp_date,
217 title=entry.get('title', '')[:128],
218 link=entry.get('link', None),
219- snippet=strip_tags(snippet)[:512],
220+ content=content,
221 )
222 article.save()
223
224@@ -114,7 +112,7 @@
225 imported = models.DateTimeField(null=True, blank=True)
226 link = models.URLField(max_length=1024, null=True, blank=True)
227 title = models.CharField(max_length=128, null=True, blank=True)
228- snippet = models.CharField(max_length=512, null=True, blank=True)
229+ content = models.TextField(null=True, blank=True)
230
231 class Meta:
232 ordering = ['-imported', '-published', ]
233
234=== modified file 'loco_directory/templates/index.html'
235--- loco_directory/templates/index.html 2012-09-25 21:01:12 +0000
236+++ loco_directory/templates/index.html 2012-12-12 23:09:21 +0000
237@@ -10,7 +10,7 @@
238 <link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}css/twidenash.css" />
239 <link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}css/continents.css" />
240 <script type="text/javascript" src="{{MEDIA_URL}}js/twidenash/jquery-twidenash.js"></script>
241- <script type="text/javascript">
242+ <script type="text/javascript">
243 //<![CDATA[
244 $(function() {
245 $('.twidenash').twidenash( {
246@@ -35,7 +35,7 @@
247 <li id="southamerica">
248 <a href="{% url team-list %}#South%20America">
249 </a>
250- </li>
251+ </li>
252 <li id="asia">
253 <a href="{% url team-list %}#Asia">
254 </a>
255@@ -51,7 +51,7 @@
256 <li id="europe">
257 <a href="{% url team-list %}#Europe">
258 </a>
259- </li>
260+ </li>
261 </ul>
262 <br />
263 <p style="text-align: center; font-weight: bold;">{% trans "Click on your continent to find teams near you." %}</p>
264@@ -63,11 +63,10 @@
265 {% for article in articles %}
266 <article class="blog-entry">
267 {% if article.source.team %}
268- <img class="blog-entry-image" src="{{ article.source.team.mugshot_url }}" />
269+ <img class="blog-entry-image" src="{{ article.source.team.mugshot_url }}" />
270 {% else %}
271 {% if article.source.user %}
272- <img class="blog-entry-image" src="{{ article.source.user.mugshot }}" />
273-
274+ <img class="blog-entry-image" src="{{ article.source.user.mugshot }}" />
275 {% endif %}
276 {% endif %}
277 <h4 class="blog-entry-title"><a href="{{ article.link }}" target="_blank">{{ article.title }}</a></h4>
278@@ -77,14 +76,15 @@
279 {% endif %}
280 {% if article.source.user %}
281 {% if article.source.team %}, {% endif %}
282- <a class="user" href="http://launchpad.net/~{{ article.source.user.user.username }}" target="_blank">{{ article.source.user }}</a>
283+ <a class="user" href="{% url profile-detail article.source.user.user.username %}" target="_blank">{{ article.source.user }}</a>
284 {% endif %}
285 </div>
286
287 <div class="blog-entry-text">
288- <p>{{ article.snippet|safe }} ... </p>
289- <p class="more"><a href="{{ article.link }}" target="_blank">{% trans 'Read More' %} ›</a>
290-</p>
291+ <p>{{ article.content|safe|striptags|truncatewords_html:100 }}</p>
292+ <p class="more">
293+ <a href="{{ article.link }}" target="_blank">{% trans 'Read More' %} ›</a>
294+ </p>
295 </div>
296 </article>
297 {% endfor %}

Subscribers

People subscribed via source and target branches