from django.contrib.sites import models as sitesModel from django.core.mail import send_mail from livesettings import config_value from custom_comments.views import comment_report from exmo2010.models import Monitoring m_pk = sys.argv[1] monitoring = Monitoring.objects.get(pk=m_pk) start_date = monitoring.interact_date limit = time_to_answer = monitoring.time_to_answer report = comment_report(monitoring) end_date = report.get('end_date') comments_without_reply = report.get('comments_without_reply') fail_comments_without_reply = report.get('fail_comments_without_reply') fail_soon_comments_without_reply = report.get('fail_soon_comments_without_reply') fail_comments_with_reply = report.get('fail_comments_with_reply') comments_with_reply = report.get('comments_with_reply') org_comments = report.get('org_comments') iifd_all_comments = report.get('iifd_all_comments') active_organization_stats = report.get('active_organization_stats') total_org = report.get('total_org') reg_org = report.get('reg_org') active_iifd_person_stats = report.get('active_iifd_person_stats') t = loader.get_template('exmo2010/helpers/score_comments_stat.html')
def monitoring_comment_report(request, id): monitoring = get_object_or_404(Monitoring, pk=id) time_to_answer = monitoring.time_to_answer if not (request.user.profile.is_expertA or request.user.is_superuser): return HttpResponseForbidden(_('Forbidden')) title = _('Comment report for %s') % monitoring form = MonitoringCommentStatForm( monitoring=monitoring, initial={'time_to_answer': time_to_answer}) start_date = monitoring.interact_date if not start_date: crumbs = ['Home', 'Monitoring'] breadcrumbs(request, crumbs) return render_to_response( "msg.html", { 'msg': _('Start date for interact not defined.') }, context_instance=RequestContext(request)) if request.method == "GET" and request.GET.__contains__('time_to_answer'): form = MonitoringCommentStatForm(request.GET, monitoring=monitoring) if form.is_valid(): time_to_answer = int(form.cleaned_data['time_to_answer']) if time_to_answer != monitoring.time_to_answer: monitoring.time_to_answer = time_to_answer monitoring.save() report = comment_report(monitoring) comments_without_reply = report.get('comments_without_reply') fail_comments_without_reply = report.get('fail_comments_without_reply') fail_soon_comments_without_reply = report.get('fail_soon_comments_without_reply') fail_comments_with_reply = report.get('fail_comments_with_reply') comments_with_reply = report.get('comments_with_reply') org_comments = report.get('org_comments') org_all_comments = report.get('org_all_comments') iifd_all_comments = report.get('iifd_all_comments') active_organization_stats = report.get('active_organization_stats') total_org = report.get('total_org') reg_org = report.get('reg_org') active_iifd_person_stats = report.get('active_iifd_person_stats') crumbs = ['Home', 'Monitoring'] breadcrumbs(request, crumbs) if request.expert: current_title = _('Monitoring cycle') else: current_title = _('Rating') if monitoring.status == 5 else _('Tasks') return render_to_response('monitoring_comment_report.html', { 'form': form, 'comments_without_reply': comments_without_reply, 'fail_comments_without_reply': fail_comments_without_reply, 'fail_soon_comments_without_reply': fail_soon_comments_without_reply, 'fail_comments_with_reply': fail_comments_with_reply, 'comments_with_reply': comments_with_reply, 'org_comments': org_comments, 'org_all_comments': org_all_comments, 'iifd_comments': iifd_all_comments, 'active_organization_stats': active_organization_stats, 'total_org': total_org.count(), 'reg_org': reg_org.count(), 'active_iifd_person_stats': active_iifd_person_stats, 'time_to_answer': time_to_answer, 'monitoring': monitoring, 'current_title': current_title, 'title': title, 'media': CORE_MEDIA, }, context_instance=RequestContext(request))