Commit e7efcb5d2c9204bad02b4fbcc04e6e903181b458

Authored by Macartur Sousa
1 parent 69786057
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

Added get_list view using list_name and MAX

Signed-off-by: Macartur Sousa <macartur.sc@gmail.com>
Signed-off-by: Alexandre Barbosa <alexandrealmeidabarbosa@gmail.com>
colab_spb/views.py
1 1 from django.shortcuts import render
2   -from django.http import HttpResponse
  2 +from django.utils.translation import ugettext as _
  3 +from colab.super_archives.models import MailingList, Thread
  4 +from colab.accounts.utils import mailman
3 5  
4   -def get_list(request,path=None,list_name=None):
5   - return HttpResponse('Hello Word')
  6 +def get_list(request):
  7 + list_name = None
  8 + MAX = 0
  9 + if request.GET.get('list_name'):
  10 + list_name = request.GET['list_name']
  11 + if request.GET.get('MAX'):
  12 + MAX = request.GET['MAX']
  13 +
  14 + context = {}
  15 +
  16 + all_privates = {}
  17 + private_mailinglist = MailingList.objects.filter(is_private=True)
  18 + for mailinglist in private_mailinglist:
  19 + all_privates[mailinglist.name] = True
  20 +
  21 + context['lists'] = []
  22 +
  23 + lists_for_user = []
  24 + if request.user.is_authenticated():
  25 + user = User.objects.get(username=request.user)
  26 + lists_for_user = mailman.get_user_mailinglists(user)
  27 +
  28 + for list_ in MailingList.objects.filter(name=list_name):
  29 + if list_.name not in all_privates or list_.name in lists_for_user:
  30 + context['lists'].append((
  31 + list_.name,
  32 + mailman.get_list_description(list_.name),
  33 + list_.thread_set.filter(spam=False).order_by(
  34 + '-latest_message__received_time'
  35 + )[:MAX],
  36 + [t.latest_message for t in Thread.highest_score.filter(
  37 + mailinglist__name=list_.name)[:MAX]],
  38 + len(mailman.list_users(list_.name)),
  39 + ))
  40 +
  41 + return render(request,"discussion.html",context)
... ...
templates/discussion.html 0 → 100644
... ... @@ -0,0 +1,49 @@
  1 +
  2 + {% load i18n %}
  3 + <h2>{% trans 'Groups'|title %}</h2>
  4 + <hr/>
  5 +
  6 + {% for listname, description, latest, most_relevant, number_of_users in lists %}
  7 + {% if latest or most_relevant %}
  8 + <h3><b>{{ listname|title|lower }} {% if description %} ({{ description }}){% endif %}</b></h3>
  9 + <div class="btn-group btn-group-sm">
  10 + <a href="#" class="btn btn-default" disabled="disabled">{% blocktrans %}{{ number_of_users }} members{% endblocktrans %}</a>
  11 + {% if proxy.trac %}
  12 + <a href="/wiki/grupos/{{ listname }}" class="btn btn-default">Wiki</a>
  13 + {% endif %}
  14 + </div>
  15 + <hr/>
  16 +
  17 + <div class="row">
  18 + <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
  19 + <h4>{% trans 'latest'|title %}</h4>
  20 + <ul class="message-list">
  21 + {% for thread in latest %}
  22 + {% include "message-preview.html" with result=thread.latest_message %}
  23 + {% endfor %}
  24 + </ul>
  25 + <div class="text-right">
  26 + <a href="{% url 'haystack_search' %}?order=latest&list={{ listname }}&type=thread">
  27 + {% trans "more..." %}
  28 + </a>
  29 + </div>
  30 + </div>
  31 +
  32 + <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
  33 + <h4>{% trans 'most relevant'|title %}</h4>
  34 + <ul class="message-list">
  35 + {% for thread in most_relevant %}
  36 + {% include "message-preview.html" with result=thread %}
  37 + {% endfor %}
  38 + </ul>
  39 + <div class="text-right">
  40 + <a href="{% url 'haystack_search' %}?list={{ listname }}&type=thread">
  41 + {% trans "more..." %}
  42 + </a>
  43 + </div>
  44 + </div>
  45 + </div>
  46 +
  47 +
  48 + {% endif %}
  49 + {% endfor %}
... ...
urls.py
... ... @@ -2,6 +2,6 @@ from django.conf.urls import patterns, url
2 2 from . import views
3 3  
4 4 urlpatterns = patterns('',
5   - url( r'^(?P<path>.*)$', views.get_list, name='get_list'),
  5 + url( r'^get_list/$',views.get_list, name='get_list'),
6 6 )
7 7  
... ...