diff options
author | Adolfo Fitoria <fitoria@fitoria-laptop.(none)> | 2009-10-13 11:16:02 -0600 |
---|---|---|
committer | Adolfo Fitoria <fitoria@fitoria-laptop.(none)> | 2009-10-13 11:16:02 -0600 |
commit | b7f549bcd89c1f29757a91c54e2ef4e175a31d1c (patch) | |
tree | f540100d0546ed6031d01465f27bede2c424ff67 | |
parent | 9dbe90c68d6503ad8a1dae8d7f8e75cbcf7b721b (diff) | |
download | askbot-b7f549bcd89c1f29757a91c54e2ef4e175a31d1c.tar.gz askbot-b7f549bcd89c1f29757a91c54e2ef4e175a31d1c.tar.bz2 askbot-b7f549bcd89c1f29757a91c54e2ef4e175a31d1c.zip |
removing categories feature from master
-rw-r--r-- | forum/admin.py | 4 | ||||
-rw-r--r-- | forum/forms.py | 4 | ||||
-rw-r--r-- | forum/managers.py | 4 | ||||
-rw-r--r-- | forum/models.py | 10 | ||||
-rw-r--r-- | forum/views.py | 40 | ||||
-rw-r--r-- | templates/categories.html | 56 | ||||
-rw-r--r-- | urls.py | 2 |
7 files changed, 1 insertions, 119 deletions
diff --git a/forum/admin.py b/forum/admin.py index e841aacb..810ae3d0 100644 --- a/forum/admin.py +++ b/forum/admin.py @@ -13,9 +13,6 @@ class QuestionAdmin(admin.ModelAdmin): class TagAdmin(admin.ModelAdmin): """Tag admin class""" -class CategoryAdmin(admin.ModelAdmin): - """Category admin class""" - class Answerdmin(admin.ModelAdmin): """Answer admin class""" @@ -52,7 +49,6 @@ class ActivityAdmin(admin.ModelAdmin): admin.site.register(Question, QuestionAdmin) admin.site.register(Tag, TagAdmin) -admin.site.register(Category, CategoryAdmin) admin.site.register(Answer, Answerdmin) admin.site.register(Comment, CommentAdmin) admin.site.register(Vote, VoteAdmin) diff --git a/forum/forms.py b/forum/forms.py index 127210c5..98ae3cbb 100644 --- a/forum/forms.py +++ b/forum/forms.py @@ -95,8 +95,6 @@ class AskForm(forms.Form): tags = TagNamesField() wiki = WikiField() - categories = forms.ModelChoiceField(help_text=_('please choice a category'), - queryset=Category.objects.all(), label=_('Category')) openid = forms.CharField(required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 40, 'class':'openid-input'})) user = forms.CharField(required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35})) email = forms.CharField(required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35})) @@ -156,8 +154,6 @@ class EditQuestionForm(forms.Form): tags = TagNamesField() summary = SummaryField() - categories = forms.ModelChoiceField(help_text=_('please choice a category'), - queryset=Category.objects.all(), label=_('Category')) def __init__(self, question, revision, *args, **kwargs): super(EditQuestionForm, self).__init__(*args, **kwargs) diff --git a/forum/managers.py b/forum/managers.py index e05aed53..31528428 100644 --- a/forum/managers.py +++ b/forum/managers.py @@ -19,10 +19,6 @@ class QuestionManager(models.Manager): questions = self.filter(deleted=False, tags__name = unquote(tagname)).order_by(orderby) return questions - def get_questions_by_category(self, categoryname, orderby): - questions = self.filter(category__name = categoryname).order_by(orderby) - return questions - def get_unanswered_questions(self, orderby): questions = self.filter(deleted=False, answer_accepted=False).order_by(orderby) return questions diff --git a/forum/models.py b/forum/models.py index f07d2879..3d752db0 100644 --- a/forum/models.py +++ b/forum/models.py @@ -18,15 +18,6 @@ import settings from forum.managers import * from const import * -class Category(models.Model): - name = models.CharField(max_length=50, unique = True) - - def __unicode__(self): - return self.name - - def get_absolute_url(self): - return '%s%s' % ('/categorias/',self.name) - class EmailFeed(models.Model): #subscription key for unsubscribe by visiting emailed link key = models.CharField(max_length=32) @@ -132,7 +123,6 @@ class Question(models.Model): author = models.ForeignKey(User, related_name='questions') added_at = models.DateTimeField(default=datetime.datetime.now) tags = models.ManyToManyField(Tag, related_name='questions') - category = models.ForeignKey(Category, related_name='questions') # Status wiki = models.BooleanField(default=False) wikified_at = models.DateTimeField(null=True, blank=True) diff --git a/forum/views.py b/forum/views.py index 9a974114..6c79bfbd 100644 --- a/forum/views.py +++ b/forum/views.py @@ -108,7 +108,7 @@ def privacy(request): def unanswered(request): return questions(request, unanswered=True) -def questions(request, tagname=None, categoryname=None, unanswered=False): +def questions(request, tagname=None, unanswered=False): """ List of Questions, Tagged questions, and Unanswered questions. """ @@ -137,8 +137,6 @@ def questions(request, tagname=None, categoryname=None, unanswered=False): #check if request is from unanswered questions template_file = "unanswered.html" objects = Question.objects.get_unanswered_questions(orderby) - elif categoryname: - objects = Question.objects.get_questions_by_category(categoryname, orderby) else: objects = Question.objects.get_questions(orderby) @@ -275,7 +273,6 @@ def ask(request): text = form.cleaned_data['text'] html = sanitize_html(markdowner.convert(text)) summary = strip_tags(html)[:120] - category = form.cleaned_data['categories'] if request.user.is_authenticated(): author = request.user @@ -510,7 +507,6 @@ def _edit_question(request, question): 'tagnames': form.cleaned_data['tags'], 'summary': strip_tags(html)[:120], 'html': html, - 'category': form.cleaned_data['categories'] } # only save when it's checked @@ -745,40 +741,6 @@ def tags(request): def tag(request, tag): return questions(request, tagname=tag) -def categories(request): - is_paginated = True - sortby = request.GET.get('sort', 'used') - try: - page = int(request.GET.get('page', '1')) - except ValueError: - page = 1 - - if request.method == "GET": - objects_list = Paginator(Category.objects.all(), DEFAULT_PAGE_SIZE) - - try: - categories = objects_list.page(page) - except (EmptyPage, InvalidPage): - categories = objects_list.page(objects_list.num_pages) - - return render_to_response('categories.html', { - "categories" : categories, - "context" : { - 'is_paginated' : is_paginated, - 'pages': objects_list.num_pages, - 'page': page, - 'has_previous': categories.has_previous(), - 'has_next': categories.has_next(), - 'previous': categories.previous_page_number(), - 'next': categories.next_page_number(), - 'base_url': '/categorias/' - } - - }, context_instance=RequestContext(request)) - -def category(request, category): - return questions(request, categoryname=category.replace('-', ' ')) - def vote(request, id): """ vote_type: diff --git a/templates/categories.html b/templates/categories.html deleted file mode 100644 index c77bd642..00000000 --- a/templates/categories.html +++ /dev/null @@ -1,56 +0,0 @@ -{% extends "base_content.html" %} -<!-- tags.html --> -{% load i18n %} -{% load extra_tags %} -{% load humanize %} -{% block title %}{% spaceless %}{% trans "Category list" %}{% endspaceless %}{% endblock %} -{% block forejs %} - <script type="text/javascript"> - $().ready(function(){ - $("#nav_tags").attr('className',"on"); - $("#ipSearchTag").focus(); - - var orderby = "{{ tab_id }}"; - if(orderby != "used" && orderby != "name") - orderby = "used"; - $("#sort_" + orderby).attr('className',"on"); - $("#type-tag").attr('checked',true); - - Hilite.exact = false; - Hilite.elementid = "searchtags"; - Hilite.debug_referrer = location.href; - }); - - </script> -{% endblock %} -{% block content %} -<!-- Tabs --> -<div class="tabBar"> - <div class="headQuestions">{% trans "Category list" %}</div> -</div> -<div id="searchtags"> -<p> -{% if not categories.object_list %} - <span>{% trans "Nothing found" %}</span> -{% endif %} -</p> -<ul class="tagsList tags"> -{% for category in categories.object_list %} - <li> - <a href="{% url forum.views.category category|slugify %}" title="{% trans "see questions that matches" %}'{{ category }}'{% trans "category " %}" rel="tag"> - {{ category }} - </a> - <br> - - </li> -{% endfor %} -</ul> -</div> - -{% endblock %} -{% block tail %} -<div class="pager"> - {% cnprog_paginator context %} -</div> -{% endblock %} -<!-- end tags.html --> @@ -67,6 +67,4 @@ urlpatterns = patterns('', url(r'^%s%s(?P<short_name>[^/]+)/$' % (_('books/'), _('ask/')), app.ask_book, name='ask_book'), url(r'^%s(?P<short_name>[^/]+)/$' % _('books/'), app.book, name='book'), url(r'^%s$' % _('search/'), app.search, name='search'), - (r'^categorias/$', app.categories), - (r'^categorias/(?P<category>[^/]+)/$', app.category), ) |