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

Contents of /trunk/htdocs/adminpanel.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 149 - (show annotations) (download) (as text)
Fri Sep 23 06:34:51 2005 UTC (8 years, 6 months ago) by hadfield
File MIME type: text/x-python
File size: 4110 byte(s)
more adminpanel implementation. implemented the news db access module.
1 # Copyright 2005 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 #
4
5 """The administration panel."""
6
7 __revision__ = "$Id$"
8 __author__ = "Scott Hadfield <hadfield@gentoo.org>"
9 __modulename__ = "adminpanel"
10
11 import os
12
13 from harmonious.utils import exposed, default
14
15 from glsr.core import fieldparse
16 from glsr.setup import config
17 from glsr.site import auth, basedomain, script, stat, user
18
19 class Adminpanel(basedomain.BaseDomain):
20
21 @default
22 @exposed
23 @auth.restricted((user.ADMIN,))
24 def stats(self):
25
26 self._do_header("Administration Console")
27 self._set_template(os.path.join(config.template_loc,
28 'admin/index.tpl'))
29 self._template.param("SCRIPT_COUNT", stat.count("script"))
30 self._template.param("USER_COUNT", stat.count("user"))
31 self._template.param("DBSIZE", stat.dbsize())
32 self._template.param("ONLINE_LOOP", [])
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"])
103
104 self._do_header("Administration Console")
105 self._set_template(os.path.join(config.template_loc,
106 'admin/news.tpl'))
107
108 self._template.param("SHOW_NEWS", show_news)
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
115 self._harm.response.append_body(self._template.output())
116 self._do_footer()

Properties

Name Value
svn:keywords Id

  ViewVC Help
Powered by ViewVC 1.1.20