[Oi-commits] r1332 - in trunk: forum profile templates/forum templates/user
oi-commits at pardus.org.tr
oi-commits at pardus.org.tr
Sun May 4 17:25:01 EEST 2008
Author: erenturkay
Date: Sun May 4 17:25:01 2008
New Revision: 1332
Added:
trunk/templates/user/followed_topics.html
Modified:
trunk/forum/forms.py
trunk/forum/urls.py
trunk/forum/views.py
trunk/profile/models.py
trunk/profile/urls.py
trunk/profile/views.py
trunk/templates/forum/forum_header.html
trunk/templates/forum/merge.html
trunk/templates/user/profile_edit.html
trunk/templates/user/user_list.html
Log:
* add followed topics delete/add support.
* change URLs that's written with _, it's ugly.
Modified: trunk/forum/forms.py
=================================================================
--- trunk/forum/forms.py (original)
+++ trunk/forum/forms.py Sun May 4 17:25:01 2008
@@ -6,7 +6,7 @@
# See the file http://www.gnu.org/copyleft/gpl.txt.
from django import newforms as forms
-from oi.forum.models import Topic, Forum
+from oi.forum.models import Topic, Forum, WatchList
from oi.st.models import Tag
from oi.st.forms import XssField
@@ -20,7 +20,7 @@
tags = forms.MultipleChoiceField(label='Etiket', required=True,help_text="CTRL basılı tutarak birden fazla etiket seçebilirsiniz!(En çok 5)")
def __init__(self,*args,**kwargs):
- """ It is for topic tihng they are dinamyc"""
+ """ It is for topic thing they are dynamic"""
super(TopicForm, self).__init__(*args, **kwargs)
self.fields['tags'].choices=[(tag.name, tag.name) for tag in Tag.objects.all()]
@@ -51,3 +51,13 @@
""" This is for collecting forums """
super(MoveForm, self).__init__(*args, **kwargs)
self.fields['forum2'].choices=[(forum.id, forum.name) for forum in Forum.objects.order_by("name")]
+
+
+# A form that is used in profile page displaying topics that user is following.
+class TopicWatchForm(forms.Form):
+ topic_watch_list = forms.MultipleChoiceField(label="Takip ettiğim konular", required=False, help_text="CTRL basılı tutarak birden fazla konu seçebilirsiniz")
+
+ # topic list generator according to user object.
+ def __init__(self, userObj, *args, **kwargs):
+ super(TopicWatchForm, self).__init__(*args, **kwargs)
+ self.fields['topic_watch_list'].choices = [(watch.topic.id, watch.topic.title) for watch in WatchList.objects.filter(user__username=userObj.username)]
Modified: trunk/forum/urls.py
=================================================================
--- trunk/forum/urls.py (original)
+++ trunk/forum/urls.py Sun May 4 17:25:01 2008
@@ -27,8 +27,8 @@
(r'^atom/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': atom_dict}),
#(r'^okunmamis_konular/$', 'oi.forum.views.unread_topics'),
- (r'^son_iletiler/$', 'oi.forum.views.latest_posts'),
- (r'^tumunu_okunmus_say/$', 'oi.forum.views.mark_all_as_read'),
+ (r'^son-iletiler/$', 'oi.forum.views.latest_posts'),
+ (r'^tumunu-okunmus-say/$', 'oi.forum.views.mark_all_as_read'),
(r'^(?P<forum_slug>.*)/(?P<topic_id>\d+)/delete/(?P<post_id>\d+)/$','oi.forum.views.delete_post'),
(r'^(?P<forum_slug>.*)/new/$', 'oi.forum.views.new_topic'),
(r'^(?P<forum_slug>.*)/(?P<topic_id>\d+)/quote/(?P<quote_id>\d+)/$', 'oi.forum.views.reply'),
Modified: trunk/forum/views.py
=================================================================
--- trunk/forum/views.py (original)
+++ trunk/forum/views.py Sun May 4 17:25:01 2008
@@ -25,7 +25,7 @@
# import our function for sending e-mails and setting
from oi.st.wrappers import send_mail_with_header
-from oi.settings import FORUM_FROM_EMAIL, FORUM_TO_EMAIL, WEB_URL
+from oi.settings import FORUM_FROM_EMAIL, WEB_URL
# import bbcode renderer for quotation
from oi.forum.postmarkup import render_bbcode
Modified: trunk/profile/models.py
=================================================================
--- trunk/profile/models.py (original)
+++ trunk/profile/models.py Sun May 4 17:25:01 2008
@@ -95,7 +95,7 @@
class Admin:
fields = (
- ('Üyelik Bilgileri', {'fields': ('user', 'avatar', 'homepage', 'msn', 'city', 'birthday', 'contributes', 'contributes_summary', 'show_email',)}),
+ ('Üyelik Bilgileri', {'fields': ('user', 'avatar', 'homepage', 'msn', 'city', 'birthday', 'contributes', 'contributes_summary', 'show_email', 'latitude', 'longitude',)}),
('Diğer', {'fields': ('activation_key', 'key_expires', 'signature'), 'classes': 'collapse',}),
)
Modified: trunk/profile/urls.py
=================================================================
--- trunk/profile/urls.py (original)
+++ trunk/profile/urls.py Sun May 4 17:25:01 2008
@@ -21,13 +21,14 @@
(r'^liste/$', 'django.views.generic.simple.redirect_to', {'url': "sayfa/1/"}),
(r'^liste/sayfa/(?P<page>[0-9]+)/$', 'django.views.generic.list_detail.object_list', dict(user_dict)),
#the tested ones
+ (r'^takip-ettigim-konular/$', 'oi.profile.views.followed_topics'),
(r'^giris/$', 'django.contrib.auth.views.login', {'template_name': 'user/login.html'}),
(r'^cikis/$', 'django.contrib.auth.views.logout', {'template_name': 'user/logout.html'}),
(r'^kayit/$', 'oi.profile.views.user_register'),
(r'^onay/(?P<name>[\w-]+)/(?P<key>[\w-]+)/$', 'oi.profile.views.user_confirm'),
(r'^duzenle/$', 'oi.profile.views.user_profile_edit'),
(r'^sayfam/$', 'oi.profile.views.user_dashboard'),
- (r'^parola_degistir/$', 'oi.profile.views.change_password'),
+ (r'^parola-degistir/$', 'oi.profile.views.change_password'),
(r'^kayip/$', 'oi.profile.views.lost_password'),
(r'^kayip/degistir/(?P<key>[\w-]+)/$', 'oi.profile.views.reset_password'),
#(r'^kullanici/(?P<name>[\w-]+)/yorumlar/$', 'oi.profile.views.user_comments'),
Modified: trunk/profile/views.py
=================================================================
--- trunk/profile/views.py (original)
+++ trunk/profile/views.py Sun May 4 17:25:01 2008
@@ -8,7 +8,7 @@
import sha, datetime, random
from os import path
-from django.http import HttpResponseRedirect
+from django.http import HttpResponseRedirect, HttpResponse
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
@@ -17,6 +17,10 @@
from oi.settings import DEFAULT_FROM_EMAIL, LOGIN_URL, WEB_URL, PROFILE_EDIT_URL
+# Form and Model objects for followed topics
+from oi.forum.models import WatchList
+from oi.forum.forms import TopicWatchForm
+
from oi.profile.models import Avatar, Profile, LostPassword
from oi.profile.forms import RegisterForm, ProfileEditForm, LostPasswordForm, ChangePasswordForm, ResetPasswordForm
from oi.profile.settings import googleMapsApiKey
@@ -24,6 +28,26 @@
from oi.petition.models import Petitioner
@login_required
+def followed_topics(request):
+ print request
+ if request.method == 'POST':
+ list = request.POST.getlist('topic_watch_list')
+ if list:
+ for id in list:
+ # control if posted topic id belongs to user
+ if not WatchList.objects.filter(topic__id=id).filter(user__username=request.user.username):
+ return HttpResponse('You idiot! Are you trying to hack us?')
+ else:
+ WatchList.objects.filter(topic__id=id).filter(user__username=request.user.username).delete()
+ # FIXME: Shouldn't be hardcoded.
+ return HttpResponseRedirect('/kullanici/takip-ettigim-konular/')
+ else:
+ if len(WatchList.objects.filter(user__username=request.user.username)) == 0:
+ return render_response(request, 'user/followed_topics.html', {'no_entry': True})
+ else:
+ return render_response(request, 'user/followed_topics.html', {'form': TopicWatchForm(request.user)})
+
+ at login_required
def user_dashboard(request):
return render_response(request, 'user/dashboard.html')
Modified: trunk/templates/forum/forum_header.html
=================================================================
--- trunk/templates/forum/forum_header.html (original)
+++ trunk/templates/forum/forum_header.html Sun May 4 17:25:01 2008
@@ -16,7 +16,7 @@
{% else %}
<div>
Hoşgeldin <b>{{ user.username }}</b>!<br />
- <a href="/kullanici/profil/{{ user.username }}/" style="text-decoration:none">Profil</a> | <a href="/forum/son_iletiler/" style="text-decoration:none">Son İletiler</a> | <a href="/forum/tumunu_okunmus_say/?next={{ request.path }}" style="text-decoration:none">Tümünü Okunmuş Say</a> | <a class="sari" href="/kullanici/cikis/" style="text-decoration:none">Çıkış</a>
+ <a href="/kullanici/profil/{{ user.username }}/" style="text-decoration:none">Profil</a> | <a href="/forum/son-iletiler/" style="text-decoration:none">Son İletiler</a> | <a href="/forum/tumunu-okunmus-say/?next={{ request.path }}" style="text-decoration:none">Tümünü Okunmuş Say</a> | <a class="sari" href="/kullanici/takip-ettigim-konular/" style="text-decoration:none">Takip Ettiğim Konular</a> | <a class="sari" href="/kullanici/cikis/" style="text-decoration:none">Çıkış</a>
</div>
{% endif %}
</div>
Modified: trunk/templates/forum/merge.html
=================================================================
--- trunk/templates/forum/merge.html (original)
+++ trunk/templates/forum/merge.html Sun May 4 17:25:01 2008
@@ -7,8 +7,8 @@
<dl>
<dt>{{ form.topic2.label_tag }}</dt>
<dd>{{ form.topic2 }}</dd>
- {% if form.topic2.help_text %}<dd>{{ field.topic2.help_text }}</dd>{% endif %}
- {% if form.topic2.errors %}<dd class="myerrors">{{ field.topic2.errors }}</dd>{% endif %}
+ {% if form.topic2.help_text %}<dd>{{ form.topic2.help_text }}</dd>{% endif %}
+ {% if form.topic2.errors %}<dd class="myerrors">{{ form.topic2.errors }}</dd>{% endif %}
</dl>
<input type="submit" value="Merge">
</form>
Modified: trunk/templates/user/profile_edit.html
=================================================================
--- trunk/templates/user/profile_edit.html (original)
+++ trunk/templates/user/profile_edit.html Sun May 4 17:25:01 2008
@@ -86,7 +86,7 @@
{% endfor %}
<dl><dt><label for="id_map">Harita</label><dt><div id="id_map" class="googlemap"></div></dt></dl>
<div style="clear:left; text-align:center; padding-top:5px;"><input type="submit" value="Düzenle" /></div>
- <div style="clear:left; text-align:center;"><a href="/kullanici/parola_degistir/">Parolayı Değiştir</a></div>
+ <div style="clear:left; text-align:center; margin-top: 6px;"><a href="/kullanici/parola-degistir/">Parolayı Değiştir</a></div>
</form>
{% endblock %}
Modified: trunk/templates/user/user_list.html
=================================================================
--- trunk/templates/user/user_list.html (original)
+++ trunk/templates/user/user_list.html Sun May 4 17:25:01 2008
@@ -19,7 +19,6 @@
{% block content %}
-
{% for user in user_list %}
Name: {{ user.username }} <br />
{% endfor %}
More information about the Oi-commits
mailing list