|
1 |
# w.c.s. - web application for online forms
|
|
2 |
# Copyright (C) 2005-2010 Entr'ouvert
|
|
3 |
#
|
|
4 |
# This program is free software; you can redistribute it and/or modify
|
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
8 |
#
|
|
9 |
# This program is distributed in the hope that it will be useful,
|
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
13 |
#
|
|
14 |
# You should have received a copy of the GNU General Public License
|
|
15 |
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
16 |
|
|
17 |
import os
|
|
18 |
|
|
19 |
from qommon.ctl import Command, make_option
|
|
20 |
|
|
21 |
|
|
22 |
class EmptyForms(Command):
|
|
23 |
name = 'empty_forms'
|
|
24 |
|
|
25 |
def __init__(self):
|
|
26 |
Command.__init__(self, [
|
|
27 |
make_option('--all', action='store_true',
|
|
28 |
dest='all', default=False),
|
|
29 |
])
|
|
30 |
|
|
31 |
def execute(self, base_options, sub_options, args):
|
|
32 |
import publisher
|
|
33 |
from wcs.formdef import FormDef
|
|
34 |
|
|
35 |
publisher.WcsPublisher.configure(self.config)
|
|
36 |
pub = publisher.WcsPublisher.create_publisher(
|
|
37 |
register_cron=False, register_tld_names=False)
|
|
38 |
app_dir = pub.app_dir
|
|
39 |
|
|
40 |
if sub_options.all:
|
|
41 |
hostnames = publisher.WcsPublisher.get_tenants()
|
|
42 |
else:
|
|
43 |
hostnames = args
|
|
44 |
for hostname in hostnames:
|
|
45 |
pub.app_dir = os.path.join(app_dir, hostname)
|
|
46 |
|
|
47 |
for formdef in FormDef.select():
|
|
48 |
formdata = formdef.data_class()
|
|
49 |
formdata.wipe()
|
|
50 |
|
|
51 |
EmptyForms.register()
|
0 |
|
-
|