Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I have solved my question myself.

here is the key code below.

def inbox(request, account_id): ''' Gets a single question '''

#print repr(account_id) user = get_object_or_404(User, last_name=account_id) data = get_user_data(user) #print repr(data)

activity_types = const.RESPONSE_ACTIVITY_TYPES_FOR_DISPLAY activity_types += (const.TYPE_ACTIVITY_MENTION,)

memo_set = user.get_notifications(activity_types) memo_set = memo_set.select_related( 'activity', 'activity__content_type', 'activity__question__thread', 'activity__user', 'activity__user__askbot_profile__gravatar', ).order_by( '-activity__active_at' )[:const.USER_VIEW_DATA_SIZE]

response_list = list() for memo in memo_set: obj = memo.activity.content_object if obj is None: memo.activity.delete() continue#a temp plug due to bug in the comment deletion

act = memo.activity act_user = act.user act_message = act.get_activity_type_display() act_type = 'edit'

response = { 'id': memo.id, 'timestamp': str(act.active_at), 'user': str(act_user), 'is_new': memo.is_new(), 'url': act.get_absolute_url(), 'snippet': act.get_snippet(), 'title': act.question.thread.title, 'message_type': act_message, 'memo_type': act_type, 'question_id': act.question.id, 'followup_messages': list(), 'content': obj.html or obj.text, }

if memo.is_new(): response_list.append(response)

json_string = simplejson.dumps(response_list) return HttpResponse(json_string, content_type='application/json')

I have solved my question myself.

here is the key code below.

def inbox(request, account_id): ''' Gets a single question '''

#print repr(account_id) repr(account_id)

user = get_object_or_404(User, last_name=account_id) last_name=account_id)

data = get_user_data(user) get_user_data(user)

#print repr(data)

activity_types = const.RESPONSE_ACTIVITY_TYPES_FOR_DISPLAY const.RESPONSE_ACTIVITY_TYPES_FOR_DISPLAY

activity_types += (const.TYPE_ACTIVITY_MENTION,)

memo_set = user.get_notifications(activity_types) user.get_notifications(activity_types)

memo_set = memo_set.select_related( 'activity', 'activity__content_type', 'activity__question__thread', 'activity__user', 'activity__user__askbot_profile__gravatar', ).order_by( '-activity__active_at' )[:const.USER_VIEW_DATA_SIZE]

response_list = list() list()

for memo in memo_set: obj = memo.activity.content_object if obj is None: memo.activity.delete() continue#a temp plug due to bug in the comment deletion

act = memo.activity memo.activity

act_user = act.user act.user

act_message = act.get_activity_type_display() act.get_activity_type_display()

act_type = 'edit'

response = { 'id': memo.id, 'timestamp': str(act.active_at), 'user': str(act_user), 'is_new': memo.is_new(), 'url': act.get_absolute_url(), 'snippet': act.get_snippet(), 'title': act.question.thread.title, 'message_type': act_message, 'memo_type': act_type, 'question_id': act.question.id, 'followup_messages': list(), 'content': obj.html or obj.text, }

if memo.is_new(): memo.is_new():

response_list.append(response)

json_string = simplejson.dumps(response_list)

json_string = simplejson.dumps(response_list) return HttpResponse(json_string, content_type='application/json')

I have solved my question myself.

here is the key code below.

def inbox(request, account_id): ''' Gets a single question '''

#print repr(account_id)

repr(account_id) user = get_object_or_404(User, last_name=account_id)

last_name=account_id) data = get_user_data(user)

get_user_data(user) #print repr(data)

repr(data) activity_types = const.RESPONSE_ACTIVITY_TYPES_FOR_DISPLAY

const.RESPONSE_ACTIVITY_TYPES_FOR_DISPLAY activity_types += (const.TYPE_ACTIVITY_MENTION,)

(const.TYPE_ACTIVITY_MENTION,) memo_set = user.get_notifications(activity_types)

user.get_notifications(activity_types) memo_set = memo_set.select_related( 'activity', 'activity__content_type', 'activity__question__thread', 'activity__user', 'activity__user__askbot_profile__gravatar', ).order_by( '-activity__active_at' )[:const.USER_VIEW_DATA_SIZE]

)[:const.USER_VIEW_DATA_SIZE] response_list = list()

list() for memo in memo_set: obj = memo.activity.content_object if obj is None: memo.activity.delete() continue#a temp plug due to bug in the comment deletion

deletion act = memo.activity

memo.activity act_user = act.user

act.user act_message = act.get_activity_type_display()

act.get_activity_type_display() act_type = 'edit'

'edit' response = { 'id': memo.id, 'timestamp': str(act.active_at), 'user': str(act_user), 'is_new': memo.is_new(), 'url': act.get_absolute_url(), 'snippet': act.get_snippet(), 'title': act.question.thread.title, 'message_type': act_message, 'memo_type': act_type, 'question_id': act.question.id, 'followup_messages': list(), 'content': obj.html or obj.text, }

} if memo.is_new():

response_list.append(response)

memo.is_new(): response_list.append(response) json_string = simplejson.dumps(response_list)

simplejson.dumps(response_list) return HttpResponse(json_string, content_type='application/json')

I have solved my question myself.

here is the key code below.

def inbox(request, account_id): ''' Gets a single question '''

#print repr(account_id)
 user = get_object_or_404(User, last_name=account_id)
 data = get_user_data(user)
 #print repr(data)
 activity_types = const.RESPONSE_ACTIVITY_TYPES_FOR_DISPLAY
 activity_types += (const.TYPE_ACTIVITY_MENTION,)
 memo_set = user.get_notifications(activity_types)

memo_set = memo_set.select_related(
                'activity',
                'activity__content_type',
                'activity__question__thread',
                'activity__user',
                'activity__user__askbot_profile__gravatar',
            ).order_by(
                '-activity__active_at'
            )[:const.USER_VIEW_DATA_SIZE]

response_list = list()
 for memo in memo_set:
    obj = memo.activity.content_object
    if obj is None:
        memo.activity.delete()
        continue#a temp plug due to bug in the comment deletion

    act = memo.activity
     act_user = act.user
    act_message = act.get_activity_type_display()
     act_type = 'edit'

    response = {
        'id': memo.id,
        'timestamp': str(act.active_at),
        'user': str(act_user),
        'is_new': memo.is_new(),
        'url': act.get_absolute_url(),
        'snippet': act.get_snippet(),
        'title': act.question.thread.title,
        'message_type': act_message,
        'memo_type': act_type,
        'question_id': act.question.id,
        'followup_messages': list(),
        'content': obj.html or obj.text,
    }

    if memo.is_new():
         response_list.append(response)

json_string = simplejson.dumps(response_list)
 return HttpResponse(json_string, content_type='application/json')

I have solved my question myself.

here is the key code below.

def inbox(request, account_id): account_id):

'''
 Gets a single question
    '''

'''

#print repr(account_id)
user = get_object_or_404(User, last_name=account_id)
data = get_user_data(user)
#print repr(data)
activity_types = const.RESPONSE_ACTIVITY_TYPES_FOR_DISPLAY
activity_types += (const.TYPE_ACTIVITY_MENTION,)
memo_set = user.get_notifications(activity_types)

memo_set = memo_set.select_related(
                'activity',
                'activity__content_type',
                'activity__question__thread',
                'activity__user',
                'activity__user__askbot_profile__gravatar',
            ).order_by(
                '-activity__active_at'
            )[:const.USER_VIEW_DATA_SIZE]

response_list = list()
for memo in memo_set:
    obj = memo.activity.content_object
    if obj is None:
        memo.activity.delete()
        continue#a temp plug due to bug in the comment deletion

    act = memo.activity
    act_user = act.user
   act_message = act.get_activity_type_display()
    act_type = 'edit'

    response = {
        'id': memo.id,
        'timestamp': str(act.active_at),
        'user': str(act_user),
        'is_new': memo.is_new(),
        'url': act.get_absolute_url(),
        'snippet': act.get_snippet(),
        'title': act.question.thread.title,
        'message_type': act_message,
        'memo_type': act_type,
        'question_id': act.question.id,
        'followup_messages': list(),
        'content': obj.html or obj.text,
    }

    if memo.is_new():
        response_list.append(response)

json_string = simplejson.dumps(response_list)
return HttpResponse(json_string, content_type='application/json')

I have solved my question myself.

here is the key code below.

def inbox(request, account_id):

'''
Gets a single question
'''
 #print repr(account_id)
user = get_object_or_404(User, last_name=account_id)
data = get_user_data(user)
#print repr(data)
activity_types = const.RESPONSE_ACTIVITY_TYPES_FOR_DISPLAY
activity_types += (const.TYPE_ACTIVITY_MENTION,)
memo_set = user.get_notifications(activity_types)

memo_set = memo_set.select_related(
                'activity',
                'activity__content_type',
                'activity__question__thread',
                'activity__user',
                'activity__user__askbot_profile__gravatar',
            ).order_by(
                '-activity__active_at'
            )[:const.USER_VIEW_DATA_SIZE]

response_list = list()
for memo in memo_set:
    obj = memo.activity.content_object
    if obj is None:
        memo.activity.delete()
        continue#a temp plug due to bug in the comment deletion

    act = memo.activity
    act_user = act.user
   act_message = act.get_activity_type_display()
    act_type = 'edit'

    response = {
        'id': memo.id,
        'timestamp': str(act.active_at),
        'user': str(act_user),
        'is_new': memo.is_new(),
        'url': act.get_absolute_url(),
        'snippet': act.get_snippet(),
        'title': act.question.thread.title,
        'message_type': act_message,
        'memo_type': act_type,
        'question_id': act.question.id,
        'followup_messages': list(),
        'content': obj.html or obj.text,
    }

    if memo.is_new():
        response_list.append(response)

json_string = simplejson.dumps(response_list)
return HttpResponse(json_string, content_type='application/json')