@@ -49,11 +49,11 @@ def generate_query_string(query_dict, overrides):
4949 return query_part
5050
5151
52- def document_stats (request , stats_type = None , document_state = None ):
53- def build_document_stats_url (stats_type_override = Ellipsis , document_state_override = Ellipsis , get_overrides = {}):
52+ def document_stats (request , stats_type = None , document_type = None ):
53+ def build_document_stats_url (stats_type_override = Ellipsis , document_type_override = Ellipsis , get_overrides = {}):
5454 kwargs = {
5555 "stats_type" : stats_type if stats_type_override is Ellipsis else stats_type_override ,
56- "document_state " : document_state if document_state_override is Ellipsis else document_state_override ,
56+ "document_type " : document_type if document_type_override is Ellipsis else document_type_override ,
5757 }
5858
5959 return urlreverse (document_stats , kwargs = { k : v for k , v in kwargs .iteritems () if v is not None }) + generate_query_string (request .GET , get_overrides )
@@ -72,33 +72,42 @@ def build_document_stats_url(stats_type_override=Ellipsis, document_state_overri
7272 if not stats_type :
7373 return HttpResponseRedirect (build_document_stats_url (stats_type_override = possible_stats_types [0 ][0 ]))
7474
75- possible_document_states = [
75+ possible_document_types = [
7676 ("all" , "All" ),
7777 ("rfc" , "RFCs" ),
78- ("draft" , "Drafts (not published as RFC) " ),
78+ ("draft" , "Drafts" ),
7979 ]
8080
81- possible_document_states = [ (slug , label , build_document_stats_url (document_state_override = slug ))
82- for slug , label in possible_document_states ]
81+ possible_document_types = [ (slug , label , build_document_stats_url (document_type_override = slug ))
82+ for slug , label in possible_document_types ]
8383
84- if not document_state :
85- return HttpResponseRedirect (build_document_stats_url (document_state_override = possible_document_states [0 ][0 ]))
84+ if not document_type :
85+ return HttpResponseRedirect (build_document_stats_url (document_type_override = possible_document_types [0 ][0 ]))
8686
8787
8888 # filter documents
8989 doc_qs = Document .objects .filter (type = "draft" )
9090
91- if document_state == "rfc" :
91+ if document_type == "rfc" :
9292 doc_qs = doc_qs .filter (states__type = "draft" , states__slug = "rfc" )
93- elif document_state == "draft" :
93+ elif document_type == "draft" :
9494 doc_qs = doc_qs .exclude (states__type = "draft" , states__slug = "rfc" )
9595
9696 chart_data = []
9797 table_data = []
98+
99+ if document_type == "all" :
100+ doc_label = "document"
101+ elif document_type == "rfc" :
102+ doc_label = "RFC"
103+ elif document_type == "draft" :
104+ doc_label = "draft"
105+
98106 stats_title = ""
99107
100108 if stats_type == "authors" :
101- stats_title = "Number of authors for each document"
109+
110+ stats_title = "Number of authors for each {}" .format (doc_label )
102111
103112 groups = defaultdict (list )
104113
@@ -114,7 +123,8 @@ def build_document_stats_url(stats_type_override=Ellipsis, document_state_overri
114123
115124 chart_data .append ({
116125 "data" : series_data ,
117- "name" : "Percentage of documents" ,
126+ "name" : "Percentage of {}s" .format (doc_label ),
127+ "animation" : False ,
118128 })
119129
120130
@@ -124,8 +134,9 @@ def build_document_stats_url(stats_type_override=Ellipsis, document_state_overri
124134 "stats_title" : stats_title ,
125135 "possible_stats_types" : possible_stats_types ,
126136 "stats_type" : stats_type ,
127- "possible_document_states" : possible_document_states ,
128- "document_state" : document_state ,
137+ "possible_document_types" : possible_document_types ,
138+ "document_type" : document_type ,
139+ "doc_label" : doc_label ,
129140 })
130141
131142@login_required
0 commit comments