askbot.models

class askbot.models.Question(*args, **kwargs)

Bases: askbot.models.content.Content, askbot.models.base.DeletableContent

Question(id, deleted, deleted_at, deleted_by_id, author_id, added_at, wiki, wikified_at, locked, locked_by_id, locked_at, score, vote_up_count, vote_down_count, comment_count, offensive_flag_count, last_edited_at, last_edited_by_id, html, text, title, answer_accepted, closed, closed_by_id, closed_at, close_reason, answer_count, view_count, favourite_count, last_activity_at, last_activity_by_id, tagnames, summary)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Question.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Question.add_revision(author=None, text=None, comment=None, revised_at=None)
Question.anonymous_answers
Question.answers
Question.apply_edit(edited_at=None, edited_by=None, title=None, text=None, comment=None, tags=None, wiki=False)
Question.author
Question.closed_by
Question.comments

This class provides the functionality that makes the related-object managers available as attributes on a model class, for fields that have multiple “remote” values and have a GenericRelation defined in their model (rather than having another model pointed at them). In the example “article.publications”, the publications attribute is a ReverseGenericRelatedObjectsDescriptor instance.

Question.delete()
Question.deleted_by
Question.favorited_by
Question.favoritequestion_set
Question.flagged_items

This class provides the functionality that makes the related-object managers available as attributes on a model class, for fields that have multiple “remote” values and have a GenericRelation defined in their model (rather than having another model pointed at them). In the example “article.publications”, the publications attribute is a ReverseGenericRelatedObjectsDescriptor instance.

Question.followed_by
Question.get_absolute_url(*moreargs, **morekwargs)
Question.get_answer_count_by_user(user_id)
Question.get_close_reason_display(*moreargs, **morekwargs)
Question.get_last_update_info()
Question.get_next_by_added_at(*moreargs, **morekwargs)
Question.get_next_by_last_activity_at(*moreargs, **morekwargs)
Question.get_origin_post()
Question.get_previous_by_added_at(*moreargs, **morekwargs)
Question.get_previous_by_last_activity_at(*moreargs, **morekwargs)
Question.get_question_title()
Question.get_response_receivers(exclude_list=None)

returns list of users who might be interested in the question update based on their participation in the question activity

exclude_list is mandatory - it normally should have the author of the update so the he/she is not notified about the update

Question.get_revision_url()
Question.get_update_summary(last_reported_at=None, recipient_email='')
Question.get_updated_activity_data(created=False)
Question.has_favorite_by_user(user)
Question.last_activity_by
Question.last_edited_by
Question.locked_by
Question.parse(post)

typically post has a field to store raw source text in comment it is called .comment, in Question and Answer it is called .text also there is another field called .html (consistent across models) so the goal of this function is to render raw text into .html and extract any metadata given stored in source (currently this metadata is limited by twitter style @mentions but there may be more in the future

function returns a dictionary with the following keys html newly_mentioned_users - list of <User> objects removed_mentions - list of mention <Activity> objects - for removed ones

Question.parse_and_save(post, author=None, **kwargs)

generic method to use with posts to be used prior to saving post edit or addition

Question.repute_set
Question.retag(retagged_by=None, retagged_at=None, tagnames=None)
Question.revisions
Question.save(**kwargs)

Overridden to manually manage addition of tags when the object is first saved.

This is required as we’re using tagnames as the sole means of adding and editing tags.

Question.tagname_list()

Creates a list of Tag names from the tagnames attribute.

Question.tagname_meta_generator()
Question.tags
Question.viewed
Question.votes

This class provides the functionality that makes the related-object managers available as attributes on a model class, for fields that have multiple “remote” values and have a GenericRelation defined in their model (rather than having another model pointed at them). In the example “article.publications”, the publications attribute is a ReverseGenericRelatedObjectsDescriptor instance.

class askbot.models.QuestionRevision(*args, **kwargs)

Bases: askbot.models.base.ContentRevision

A revision of a Question.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception QuestionRevision.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

QuestionRevision.author
QuestionRevision.get_absolute_url(*moreargs, **morekwargs)
QuestionRevision.get_next_by_revised_at(*moreargs, **morekwargs)
QuestionRevision.get_previous_by_revised_at(*moreargs, **morekwargs)
QuestionRevision.get_question_title()
QuestionRevision.question
QuestionRevision.save(**kwargs)

Looks up the next available revision number.

class askbot.models.QuestionView(*args, **kwargs)

Bases: django.db.models.base.Model

QuestionView(id, question_id, who_id, when)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception QuestionView.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

QuestionView.get_next_by_when(*moreargs, **morekwargs)
QuestionView.get_previous_by_when(*moreargs, **morekwargs)
QuestionView.question
QuestionView.who
class askbot.models.FavoriteQuestion(*args, **kwargs)

Bases: django.db.models.base.Model

A favorite Question of a User.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception FavoriteQuestion.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

FavoriteQuestion.get_next_by_added_at(*moreargs, **morekwargs)
FavoriteQuestion.get_previous_by_added_at(*moreargs, **morekwargs)
FavoriteQuestion.question
FavoriteQuestion.user
class askbot.models.AnonymousQuestion(*args, **kwargs)

Bases: askbot.models.base.AnonymousContent

AnonymousQuestion(id, session_key, wiki, added_at, ip_addr, author_id, text, summary, title, tagnames)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception AnonymousQuestion.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

AnonymousQuestion.author
AnonymousQuestion.get_next_by_added_at(*moreargs, **morekwargs)
AnonymousQuestion.get_previous_by_added_at(*moreargs, **morekwargs)
AnonymousQuestion.publish(user)
class askbot.models.Answer(*args, **kwargs)

Bases: askbot.models.content.Content, askbot.models.base.DeletableContent

Answer(id, deleted, deleted_at, deleted_by_id, author_id, added_at, wiki, wikified_at, locked, locked_by_id, locked_at, score, vote_up_count, vote_down_count, comment_count, offensive_flag_count, last_edited_at, last_edited_by_id, html, text, question_id, accepted, accepted_at)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Answer.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Answer.add_revision(revised_by=None, revised_at=None, text=None, comment=None)
Answer.apply_edit(edited_at=None, edited_by=None, text=None, comment=None, wiki=False)
Answer.author
Answer.comments

This class provides the functionality that makes the related-object managers available as attributes on a model class, for fields that have multiple “remote” values and have a GenericRelation defined in their model (rather than having another model pointed at them). In the example “article.publications”, the publications attribute is a ReverseGenericRelatedObjectsDescriptor instance.

Answer.deleted_by
Answer.flagged_items

This class provides the functionality that makes the related-object managers available as attributes on a model class, for fields that have multiple “remote” values and have a GenericRelation defined in their model (rather than having another model pointed at them). In the example “article.publications”, the publications attribute is a ReverseGenericRelatedObjectsDescriptor instance.

Answer.get_absolute_url(*moreargs, **morekwargs)
Answer.get_next_by_added_at(*moreargs, **morekwargs)
Answer.get_origin_post()
Answer.get_previous_by_added_at(*moreargs, **morekwargs)
Answer.get_question_title()
Answer.get_response_receivers(exclude_list=None)

get list of users interested in this response update based on their participation in the question activity

exclude_list is required and normally should contain author of the updated so that he/she is not notified of the response

Answer.get_updated_activity_data(created=False)
Answer.get_user_vote(user)
Answer.last_edited_by
Answer.locked_by
Answer.parse(post)

typically post has a field to store raw source text in comment it is called .comment, in Question and Answer it is called .text also there is another field called .html (consistent across models) so the goal of this function is to render raw text into .html and extract any metadata given stored in source (currently this metadata is limited by twitter style @mentions but there may be more in the future

function returns a dictionary with the following keys html newly_mentioned_users - list of <User> objects removed_mentions - list of mention <Activity> objects - for removed ones

Answer.parse_and_save(post, author=None, **kwargs)

generic method to use with posts to be used prior to saving post edit or addition

Answer.question
Answer.revisions
Answer.votes

This class provides the functionality that makes the related-object managers available as attributes on a model class, for fields that have multiple “remote” values and have a GenericRelation defined in their model (rather than having another model pointed at them). In the example “article.publications”, the publications attribute is a ReverseGenericRelatedObjectsDescriptor instance.

class askbot.models.AnswerRevision(*args, **kwargs)

Bases: askbot.models.base.ContentRevision

A revision of an Answer.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception AnswerRevision.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

AnswerRevision.answer
AnswerRevision.author
AnswerRevision.get_absolute_url(*moreargs, **morekwargs)
AnswerRevision.get_next_by_revised_at(*moreargs, **morekwargs)
AnswerRevision.get_previous_by_revised_at(*moreargs, **morekwargs)
AnswerRevision.get_question_title()
AnswerRevision.save(**kwargs)

Looks up the next available revision number if not set.

class askbot.models.AnonymousAnswer(*args, **kwargs)

Bases: askbot.models.base.AnonymousContent

AnonymousAnswer(id, session_key, wiki, added_at, ip_addr, author_id, text, summary, question_id)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception AnonymousAnswer.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

AnonymousAnswer.author
AnonymousAnswer.get_next_by_added_at(*moreargs, **morekwargs)
AnonymousAnswer.get_previous_by_added_at(*moreargs, **morekwargs)
AnonymousAnswer.publish(user)
AnonymousAnswer.question
class askbot.models.Tag(*args, **kwargs)

Bases: askbot.models.base.DeletableContent

Tag(id, deleted, deleted_at, deleted_by_id, name, created_by_id, used_count)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Tag.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Tag.created_by
Tag.deleted_by
Tag.questions
Tag.user_selections
class askbot.models.Comment(*args, **kwargs)

Bases: askbot.models.base.MetaContent, askbot.models.base.UserContent

Comment(id, user_id, content_type_id, object_id, comment, added_at, html)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Comment.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Comment.content_object

Provides a generic relation to any object through content-type/object-id fields.

Comment.content_type
Comment.delete(**kwargs)

deletes comment and concomitant response activity records, as well as mention records, while preserving integrity or response counts for the users

Comment.get_absolute_url(*moreargs, **morekwargs)
Comment.get_instant_notification_subscribers(potential_subscribers=None, mentioned_users=None, exclude_list=None)

get list of users who want instant notifications about this post

argument potential_subscribers is required as it saves on db hits

Comment.get_latest_revision_number()
Comment.get_next_by_added_at(*moreargs, **morekwargs)
Comment.get_origin_post()
Comment.get_previous_by_added_at(*moreargs, **morekwargs)
Comment.get_response_receivers(exclude_list=None)

get list of users who authored comments on a post and the post itself

Comment.get_text()
Comment.get_time_of_last_edit()
Comment.get_updated_activity_data(created=False)
Comment.parse(post)

typically post has a field to store raw source text in comment it is called .comment, in Question and Answer it is called .text also there is another field called .html (consistent across models) so the goal of this function is to render raw text into .html and extract any metadata given stored in source (currently this metadata is limited by twitter style @mentions but there may be more in the future

function returns a dictionary with the following keys html newly_mentioned_users - list of <User> objects removed_mentions - list of mention <Activity> objects - for removed ones

Comment.parse_and_save(post, author=None, **kwargs)

generic method to use with posts to be used prior to saving post edit or addition

Comment.set_text(text)
Comment.user
class askbot.models.Vote(*args, **kwargs)

Bases: askbot.models.base.MetaContent, askbot.models.base.UserContent

Vote(id, user_id, content_type_id, object_id, vote, voted_at)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Vote.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Vote.content_object

Provides a generic relation to any object through content-type/object-id fields.

Vote.content_type
Vote.get_next_by_voted_at(*moreargs, **morekwargs)
Vote.get_previous_by_voted_at(*moreargs, **morekwargs)
Vote.get_vote_display(*moreargs, **morekwargs)
Vote.is_downvote()
Vote.is_opposite(vote_type)
Vote.is_upvote()
Vote.user
class askbot.models.FlaggedItem(*args, **kwargs)

Bases: askbot.models.base.MetaContent, askbot.models.base.UserContent

A flag on a Question or Answer indicating offensive content.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception FlaggedItem.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

FlaggedItem.content_object

Provides a generic relation to any object through content-type/object-id fields.

FlaggedItem.content_type
FlaggedItem.get_next_by_flagged_at(*moreargs, **morekwargs)
FlaggedItem.get_previous_by_flagged_at(*moreargs, **morekwargs)
FlaggedItem.user
class askbot.models.MarkedTag(*args, **kwargs)

Bases: django.db.models.base.Model

MarkedTag(id, tag_id, user_id, reason)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MarkedTag.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

MarkedTag.get_reason_display(*moreargs, **morekwargs)
MarkedTag.tag
MarkedTag.user
class askbot.models.Badge(*args, **kwargs)

Bases: django.db.models.base.Model

Awarded for notable actions performed on the site by Users.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Badge.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Badge.award_badge
Badge.awarded_to
Badge.get_absolute_url(*moreargs, **morekwargs)
Badge.get_type_display(*moreargs, **morekwargs)
Badge.save(**kwargs)
class askbot.models.Award(*args, **kwargs)

Bases: django.db.models.base.Model

The awarding of a Badge to a User.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Award.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Award.badge
Award.content_object

Provides a generic relation to any object through content-type/object-id fields.

Award.content_type
Award.get_next_by_awarded_at(*moreargs, **morekwargs)
Award.get_previous_by_awarded_at(*moreargs, **morekwargs)
Award.user
class askbot.models.Repute(*args, **kwargs)

Bases: django.db.models.base.Model

The reputation histories for user

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Repute.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Repute.get_next_by_reputed_at(*moreargs, **morekwargs)
Repute.get_previous_by_reputed_at(*moreargs, **morekwargs)
Repute.get_reputation_type_display(*moreargs, **morekwargs)
Repute.question
Repute.user
class askbot.models.Activity(*args, **kwargs)

Bases: django.db.models.base.Model

We keep some history data for user activities

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Activity.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Activity.content_object

Provides a generic relation to any object through content-type/object-id fields.

Activity.content_type
Activity.get_absolute_url(*moreargs, **morekwargs)
Activity.get_activity_type_display(*moreargs, **morekwargs)
Activity.get_mentioned_user()
Activity.get_next_by_active_at(*moreargs, **morekwargs)
Activity.get_previous_by_active_at(*moreargs, **morekwargs)
Activity.receiving_users
Activity.user
class askbot.models.EmailFeedSetting(*args, **kwargs)

Bases: django.db.models.base.Model

EmailFeedSetting(id, subscriber_id, feed_type, frequency, added_at, reported_at)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception EmailFeedSetting.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

EmailFeedSetting.get_feed_type_display(*moreargs, **morekwargs)
EmailFeedSetting.get_frequency_display(*moreargs, **morekwargs)
EmailFeedSetting.get_next_by_added_at(*moreargs, **morekwargs)
EmailFeedSetting.get_previous_by_added_at(*moreargs, **morekwargs)
EmailFeedSetting.get_previous_report_cutoff_time()
EmailFeedSetting.mark_reported_now()
EmailFeedSetting.save(*args, **kwargs)
EmailFeedSetting.should_send_now()
EmailFeedSetting.subscriber
class askbot.models.User(*args, **kwargs)

Bases: django.db.models.base.Model

Users within the Django authentication system are represented by this model.

Username and password are required. Other fields are optional.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception User.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

User.accept_answer(answer, timestamp=None, cancel=False)
User.activity_set
User.anonymousanswer_set
User.anonymousquestion_set
User.answerrevisions
User.answers
User.award_user
User.badges
User.check_password(raw_password)

Returns a boolean of whether the raw_password was correct. Handles encryption formats behind the scenes.

User.closed_questions
User.comments
User.created_tags
User.decrement_response_count(user)

decrement response count for the user by one, log critical error if count would go below zero but limit decrementation at zero exactly

User.delete_messages()
User.deleted_answers
User.deleted_questions
User.deleted_tags
User.downvote(post, timestamp=None, cancel=False)
User.email_user(subject, message, from_email=None)

Sends an e-mail to this User.

User.externallogindata_set
User.favorite_questions
User.flag_post(user, post, timestamp=None, cancel=False)
User.flaggeditems
User.followed_questions
User.get_absolute_url()
User.get_all_permissions()
User.get_and_delete_messages()
User.get_full_name()

Returns the first_name plus the last_name, with a space in between.

User.get_group_permissions()

Returns a list of permission strings that this user has through his/her groups. This method queries all available auth backends.

User.get_messages()
User.get_next_by_date_joined(*moreargs, **morekwargs)
User.get_next_by_last_login(*moreargs, **morekwargs)
User.get_next_by_last_seen(*moreargs, **morekwargs)
User.get_previous_by_date_joined(*moreargs, **morekwargs)
User.get_previous_by_last_login(*moreargs, **morekwargs)
User.get_previous_by_last_seen(*moreargs, **morekwargs)
User.get_profile()

Returns site-specific profile for this user. Raises SiteProfileNotAvailable if this site does not allow profiles.

User.get_profile_url()

Returns the URL for this User’s profile.

User.get_q_sel_email_feed_frequency()
User.get_questions_per_page_display(*moreargs, **morekwargs)
User.get_tag_filter_setting_display(*moreargs, **morekwargs)
User.groups
User.has_module_perms(app_label)

Returns True if the user has any permissions in the given app label. Uses pretty much the same logic as has_perm, above.

User.has_perm(perm)

Returns True if the user has the specified permission. This method queries all available auth backends, but returns immediately if any backend returns True. Thus, a user who has permission from a single auth backend is assumed to have permission in general.

User.has_perms(perm_list)

Returns True if the user has each of the specified permissions.

User.has_usable_password()
User.increment_response_count(user)

increment response counter for user by one

User.is_anonymous()

Always returns False. This is a way of comparing User objects to anonymous users.

User.is_authenticated()

Always return True. This is a way to tell if the user has been authenticated in templates.

classmethod User.is_username_taken(username)
User.last_active_in_questions
User.last_edited_answers
User.last_edited_questions
User.locked_answers
User.locked_questions
User.logentry_set
User.message_set
User.notification_subscriptions
User.question_views
User.questionrevisions
User.questions
User.received_activity
User.repute_set
User.set_password(raw_password)
User.set_unusable_password()
User.tag_selections
User.toggle_favorite_question(question, timestamp=None, cancel=False)

cancel has no effect here, but is important for the SE loader it is hoped that toggle will work and data will be consistent but there is no guarantee, maybe it’s better to be more strict about processing the “cancel” option another strange thing is that this function unlike others below returns a value

User.upvote(post, timestamp=None, cancel=False)
User.user_favorite_questions
User.user_permissions
User.userassociation_set
User.userpasswordqueue_set
User.votes

Table Of Contents

This Page