add message

This commit is contained in:
baoliang 2020-10-22 13:36:23 +08:00
parent 3466b6c88b
commit f0d89bb08a
5 changed files with 21 additions and 1 deletions

View File

@ -45,6 +45,7 @@ urlpatterns = [
path('tasks/create_test/', views.create_test_task, path('tasks/create_test/', views.create_test_task,
name='polls_tasks_create_test'), name='polls_tasks_create_test'),
path('groups/list/', views.groups, name='polls_groups_list'), path('groups/list/', views.groups, name='polls_groups_list'),
path('groups/pick/', views.pick_groups, name='polls_groups_pick'),
path('groups/level/', views.is_level1_or_leve2, name='polls_groups_level'), path('groups/level/', views.is_level1_or_leve2, name='polls_groups_level'),
path('groups/test-room/', views.room, name='polls_group_test_room'), path('groups/test-room/', views.room, name='polls_group_test_room'),
path('groups/manager/', views.group_manager, name='polls_groups_manager'), path('groups/manager/', views.group_manager, name='polls_groups_manager'),

View File

@ -4,7 +4,7 @@ from .media import medias, my_medias, create_media, update_media, media_detail,
from .news import news_list, news_top, news_detail from .news import news_list, news_top, news_detail
from .monitor import monitor_statistics, monitor_result, media_statistics, city_ranking from .monitor import monitor_statistics, monitor_result, media_statistics, city_ranking
from .task import tasks, create_task, create_test_task, get_task from .task import tasks, create_task, create_test_task, get_task
from .group import groups, room, is_level1_or_leve2, group_member, group_manager, group_enter, group_leave from .group import groups, room, is_level1_or_leve2, group_member, group_manager, group_enter, group_leave, pick_groups
from .compartment import compartments from .compartment import compartments
from .organizations import organizations, organization_level from .organizations import organizations, organization_level
from .message import last_messages, send_text_message, is_read_message, read_message from .message import last_messages, send_text_message, is_read_message, read_message

View File

@ -47,6 +47,25 @@ def groups(request):
return JsonResponse({'status': 'success', 'message': results}, safe=False) return JsonResponse({'status': 'success', 'message': results}, safe=False)
@csrf_exempt
@polls_login_required
def pick_groups(request):
if request.method == 'POST':
return HttpResponse(status=405)
user_id = request.user.id
category = request.GET.get('category')
q = Group.objects.filter(status=1, group_admin__user__id=user_id).distinct()
groups = q.filter(classify=category) if category else q
results = []
for o in groups:
result = dict()
result['id'] = str(o.id)
print(o.id, o.name)
result['name'] = o.name
result['image'] = request.build_absolute_uri(o.image.url)
results.append(result)
return JsonResponse({'status': 'success', 'message': results}, safe=False)
@csrf_exempt @csrf_exempt
@polls_login_required @polls_login_required
def group_manager(request): def group_manager(request):