/[glsr]/trunk/htdocs/adminpanel.py
Gentoo

Diff of /trunk/htdocs/adminpanel.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 148 Revision 149
21 @default 21 @default
22 @exposed 22 @exposed
23 @auth.restricted((user.ADMIN,)) 23 @auth.restricted((user.ADMIN,))
24 def stats(self): 24 def stats(self):
25 25
26 dbsize = stat.dbsize() 26 self._do_header("Administration Console")
27 user_count = stat.count("user") 27 self._set_template(os.path.join(config.template_loc,
28 script_count = stat.count("script") 28 'admin/index.tpl'))
29 subscript_count = stat.count("subscript") 29 self._template.param("SCRIPT_COUNT", stat.count("script"))
30 comment_count = stat.count("comment") 30 self._template.param("USER_COUNT", stat.count("user"))
31 category_count = stat.count("category") 31 self._template.param("DBSIZE", stat.dbsize())
32 language_count = stat.count("language") 32 self._template.param("ONLINE_LOOP", [])
33 session_count = stat.count("session") 33 self._harm.response.append_body(self._template.output())
34 self._do_footer()
35
36 @exposed
37 @auth.restricted((user.ADMIN,))
38 def config(self):
39
40 self._do_header("Administration Console")
41 self._set_template(os.path.join(config.template_loc,
42 'admin/config.tpl'))
43 self._harm.response.append_body(self._template.output())
44 self._do_footer()
45
46 @exposed
47 @auth.restricted((user.ADMIN,))
48 def news(self):
49
50 from glsr.site import news
51
52 show_news = 1
53 modify = 0
54 news_id = "0"
55 subject = ""
56 body = ""
57
58 # Check if any news control buttons were pressed.
59 if self._harm.request.forms.has_key("show_news"):
60 show_news = 1
61
62 elif self._harm.request.forms.has_key("hide_news"):
63 show_news = 0
64
65 elif self._harm.request.forms.has_key("show_add"):
66 modify = 1
67 show_news = 0
68
69 elif self._harm.request.forms.has_key("save"):
70 modify = 1
71 show_news = 0
72 news_id = self._harm.request.forms.getvalue("news_id", "0")
73 uid = self._get_user()[0]
74 subject = self._harm.request.forms.getvalue("subject", "")
75 body = self._harm.request.forms.getvalue("body", "")
76 if news_id != "0" and news.exists(news_id):
77 # Modifying a news article
78 news_obj = news.News(news_id)
79 news_obj.update(uid, subject, body)
80 elif news_id == "0" and not news.exists(news_id):
81 # TODO: Need an error message here.
82 # Could not find specified news article.
83 pass
84 else:
85 # Creating a new article
86 news_id = news.create(uid, subject, body)
87
88 elif self._harm.request.forms.has_key("delete"):
89 news_ids = self._harm.request.forms.getlist("delete_btn")
90
91 for cur_news_id in news_ids:
92 if cur_news_id != "0" and news.exists(cur_news_id):
93 news_obj = news.News(cur_news_id)
94 news_obj.delete()
95 else:
96 # TODO: Need an error message here.
97 # Could not find specified news article.
98 pass
99 show_news = 1
100
101 news_loop = news.list_all(columns = ["news_id", "news_author_id",
102 "news_date", "news_subject"])
34 103
35 self._do_header("Administration Console") 104 self._do_header("Administration Console")
36 self._set_template(os.path.join(config.template_loc, 105 self._set_template(os.path.join(config.template_loc,
37 'admin/index.tpl')) 106 'admin/news.tpl'))
38 107
108 self._template.param("SHOW_NEWS", show_news)
39 self._template.param("ONLINE_LOOP", []) 109 self._template.param("NEWS_LOOP", news_loop)
110 self._template.param("MODIFY_NEWS", modify)
111 self._template.param("NEWS_ID", news_id)
112 self._template.param("SUBJECT", subject)
113 self._template.param("BODY", body)
114
40 self._harm.response.append_body(self._template.output()) 115 self._harm.response.append_body(self._template.output())
41 self._do_footer() 116 self._do_footer()

Legend:
Removed from v.148  
changed lines
  Added in v.149

  ViewVC Help
Powered by ViewVC 1.1.20