summaryrefslogtreecommitdiffstats
path: root/askbot/models
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-03-11 13:50:05 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-03-11 13:50:05 -0400
commit1fd1afb5e44a205d1ae51f6e8cc451c0ceb23fd0 (patch)
tree078486981946bef803131e6a81dd848b21ae8d03 /askbot/models
parent9ae940d578f896de39a07ae3ca08e34acacd3228 (diff)
parent133aa5196622e02a6799f5725188ac39ce74cc9e (diff)
downloadaskbot-1fd1afb5e44a205d1ae51f6e8cc451c0ceb23fd0.tar.gz
askbot-1fd1afb5e44a205d1ae51f6e8cc451c0ceb23fd0.tar.bz2
askbot-1fd1afb5e44a205d1ae51f6e8cc451c0ceb23fd0.zip
merged with the master branch
Diffstat (limited to 'askbot/models')
-rw-r--r--askbot/models/__init__.py14
-rw-r--r--askbot/models/question.py8
-rw-r--r--askbot/models/tag.py2
3 files changed, 21 insertions, 3 deletions
diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py
index 1c08cb0c..49ce7fae 100644
--- a/askbot/models/__init__.py
+++ b/askbot/models/__init__.py
@@ -1370,6 +1370,17 @@ def user_mark_tags(
if tagnames is None:
tagnames = list()
+ #figure out which tags don't yet exist
+ existing_tagnames = Tag.objects.filter(
+ name__in=tagnames
+ ).values_list(
+ 'name', flat=True
+ )
+ non_existing_tagnames = set(tagnames) - set(existing_tagnames)
+ #create those tags, and if tags are moderated make them suggested
+ if (len(non_existing_tagnames) > 0):
+ Tag.objects.create_in_bulk(tag_names=tagnames, user=self)
+
#below we update normal tag selections
marked_ts = MarkedTag.objects.filter(
user = self,
@@ -1535,6 +1546,9 @@ def user_delete_question(
question.deleted_at = timestamp
question.save()
+ question.thread.deleted = True
+ question.thread.save()
+
for tag in list(question.thread.tags.all()):
if tag.used_count == 1:
tag.deleted = True
diff --git a/askbot/models/question.py b/askbot/models/question.py
index d1fa7cae..51a7c24b 100644
--- a/askbot/models/question.py
+++ b/askbot/models/question.py
@@ -49,15 +49,18 @@ class ThreadQuerySet(models.query.QuerySet):
todo: implement full text search on relevant fields
"""
db_engine_name = askbot.get_database_engine_name()
+ filter_parameters = {'deleted': False}
if 'postgresql_psycopg2' in db_engine_name:
from askbot.search import postgresql
return postgresql.run_title_search(
self, search_query
+ ).filter(
+ **filter_parameters
).order_by('-relevance')
elif 'mysql' in db_engine_name and mysql.supports_full_text_search():
- filter_parameters = {'title__search': search_query}
+ filter_parameters['title__search'] = search_query
else:
- filter_parameters = {'title__icontains': search_query}
+ filter_parameters['title__icontains'] = search_query
if getattr(django_settings, 'ASKBOT_MULTILINGUAL', False):
filter_parameters['language_code'] = get_language()
@@ -550,6 +553,7 @@ class Thread(models.Model):
null=True,
blank=True
)
+ deleted = models.BooleanField(default=False, db_index=True)
#denormalized data: the core approval of the posts is made
#in the revisions. In the revisions there is more data about
diff --git a/askbot/models/tag.py b/askbot/models/tag.py
index 7b51e6db..455995e0 100644
--- a/askbot/models/tag.py
+++ b/askbot/models/tag.py
@@ -177,7 +177,7 @@ class TagManager(BaseQuerySetManager):
"""temporary function that filters out the group tags"""
return self.all()
- def create(self, name = None, created_by = None, **kwargs):
+ def create(self, name=None, created_by=None, **kwargs):
"""Creates a new tag"""
if created_by.can_create_tags() or is_preapproved_tag_name(name):
status = Tag.STATUS_ACCEPTED