From b7f549bcd89c1f29757a91c54e2ef4e175a31d1c Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Tue, 13 Oct 2009 11:16:02 -0600 Subject: removing categories feature from master --- forum/admin.py | 4 ---- forum/forms.py | 4 ---- forum/managers.py | 4 ---- forum/models.py | 10 --------- forum/views.py | 40 +-------------------------------- templates/categories.html | 56 ----------------------------------------------- urls.py | 2 -- 7 files changed, 1 insertion(+), 119 deletions(-) delete mode 100644 templates/categories.html 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" %} - -{% load i18n %} -{% load extra_tags %} -{% load humanize %} -{% block title %}{% spaceless %}{% trans "Category list" %}{% endspaceless %}{% endblock %} -{% block forejs %} - -{% endblock %} -{% block content %} - -
-
{% trans "Category list" %}
-
-
-

-{% if not categories.object_list %} - {% trans "Nothing found" %} -{% endif %} -

- -
- -{% endblock %} -{% block tail %} -
- {% cnprog_paginator context %} -
-{% endblock %} - diff --git a/urls.py b/urls.py index b3ac9cb8..0001a881 100644 --- a/urls.py +++ b/urls.py @@ -67,6 +67,4 @@ urlpatterns = patterns('', url(r'^%s%s(?P[^/]+)/$' % (_('books/'), _('ask/')), app.ask_book, name='ask_book'), url(r'^%s(?P[^/]+)/$' % _('books/'), app.book, name='book'), url(r'^%s$' % _('search/'), app.search, name='search'), - (r'^categorias/$', app.categories), - (r'^categorias/(?P[^/]+)/$', app.category), ) -- cgit v1.2.3-1-g7c22