Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
add first step for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoît Suttor committed Dec 9, 2011
1 parent 4b1eafc commit 1eba068
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 344 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTORS.txt
@@ -1,2 +1,2 @@
"", Author
"bsuttor", Author

178 changes: 0 additions & 178 deletions cirb/novac/README.txt

This file was deleted.

75 changes: 39 additions & 36 deletions cirb/novac/browser/listprivateview.py
Expand Up @@ -11,7 +11,7 @@

from cirb.novac import novacMessageFactory as _
from cirb.novac.utils import *
import urllib, logging
import urllib, logging, json

from zope.annotation.interfaces import IAnnotations

Expand All @@ -32,6 +32,7 @@ class ListprivateView(BrowserView):
implements(IListprivateView)

def __init__(self, context, request):
self.logger = logging.getLogger('cirb.novac.browser.listprivateview')
self.context = context
self.request = request
registry = getUtility(IRegistry)
Expand All @@ -54,7 +55,7 @@ def listprivate(self):
msg_error=_(u'No url for novac url')
self.portal_state = getMultiAdapter((self.context, self.request),
name=u'plone_portal_state')
user = get_user(self.request)
user = get_user(self.request, self.context)

dossier_list_url = '%s%s%s' %(self.novac_url,FOLDER_LIST_WS,user['id'])
dossier_list = called_url(dossier_list_url, [{'Content-Type':'application/json'}, {'ACCEPT':'application/json'}, {'lang':self.context.Language()}], lang=self.context.Language())
Expand Down Expand Up @@ -95,13 +96,13 @@ def listprivate(self):

# view to activate a dossier with the key
def activate_key(self):
logger = logging.getLogger('cirb.novac.browser.listprivate.activate_key')

# TODO return 'Bad Key' if 500 is returned by ws
key = urllib.quote_plus(self.request.form.get('key'))
#query_string = self.request.environ['QUERY_STRING']
#key = urllib.quote_plus(query_string.replace('key=',''))
user = get_user(self.request)
logger.info("key : %s - user : %s" % (key, user['id']))
self.logger.info("key : %s - user : %s" % (key, user['id']))
activate_url = '%s%s%s&RNHEAD=%s' %(self.novac_url,ACTIVATION,key, user['id'])
#activate_url = activate_url.encode('utf-8')
results = call_put_url(activate_url,[{'Content-Type':'application/xml'},{'RNHEAD':user['id']}], 'key=%s&RNHEAD=%s' % (key,user['id']))
Expand All @@ -117,36 +118,38 @@ def get_table_lines_folder(self):
if not dossier_list:
return '<tr id="content_list_folder" style="height: 0px;"><td></td><td></td><td></td><td></td></tr>'
results=[]
import json
jsondata = json.loads(dossier_list)
msgid = _(u"not_available")
not_avaiable = self.context.translate(msgid)
table = ''
for properties in jsondata:
result={}
try:
result['address'] = '%s, %s %s %s' % (properties['numberFrom'],
properties['streetName'], properties['zipcode'], properties['municipality'],)
except:
result['address'] = not_avaiable
result['type_dossier'] = get_properties(self.context, properties,"typeDossier")
result['municipality_owner'] = get_properties(self.context, properties,"municipalityOwner")
result['dossier_id'] = get_properties(self.context, properties,"id")
result['lang'] = get_properties(self.context, properties,"languageRequest")
result['manager'] = get_properties(self.context, properties,"manager")
result['desc'] = get_properties(self.context, properties,'object')
result['ref'] = get_properties(self.context, properties,'refNova')
result['folder_filed'] = get_properties(self.context, properties,'pointCC')
result['public_inquiry'] = get_properties(self.context, properties,'publicInquiry')
result['specific_reference'] = get_properties(self.context, properties,'specificReference')

try:
jsondata = json.loads(dossier_list)
except ValueError, e:
self.logger.error('Json value error : %s.' % e.message)
except SyntaxError, e:
self.logger.error('Json bad formatted : %s.' % e.message)

results.append(result)
table+='''
<tr class="content_list_folder">
<td><a href="%s/wawsprivate_view?id=%s">%s</a></td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
</tr>''' % (self.context.absolute_url(), result['dossier_id'], result['address'], result['ref'], result['type_dossier'],'???')
#print get_user()
return table
msgid = _(u"not_available")
not_available = self.context.translate(msgid)

table_ids = ["id","refNova","typeDossier","object","streetName",
"numberFrom", "numberTo","zipCode", "municipality",
"publicInquiry","startPublicInquiry","endPublicInquiry",
"statusPermit","codeDossier", "pointCC","dateCC",
"languageRequest","dateDossierComplet","specificReference",
"municipalityOwner", "manager"]

results = update_dossiers(jsondata, table_ids, not_available)
return make_table_rows(self.context.absolute_url(), results)


def make_table_rows(absolute_url, dossiers):
table = ''
for dossier in dossiers:
table+='''
<tr class="content_list_folder">
<td><a href="%s/wawsprivate_view?id=%s">%s</a></td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
</tr>''' % (absolute_url, dossier['id'], dossier['address'], dossier['refNova'],
dossier['typeDossier'], dossier['dateDossierComplet'])
return table

3 changes: 0 additions & 3 deletions cirb/novac/configure.zcml
Expand Up @@ -22,9 +22,6 @@

<i18n:registerTranslations directory="locales" />



<!--cmf:registerDirectory name="novac" directory="skins" recursive="True" /-->

<!-- -*- extra stuff goes here -*- -->

Expand Down
18 changes: 18 additions & 0 deletions cirb/novac/testing.py
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from plone.app.testing import PloneWithPackageLayer
from plone.app.testing import IntegrationTesting, FunctionalTesting
import cirb.novac

NOVAC = PloneWithPackageLayer(
zcml_filename="configure.zcml",
zcml_package=cirb.novac,
additional_z2_products=(),
gs_profile_id='cirb.novac:default',
name="NOVAC")

NOVAC_INTEGRATION = IntegrationTesting(
bases=(NOVAC,), name="NOVAC_INTEGRATION")


NOVAC_FUNCTIONAL = FunctionalTesting(
bases=(NOVAC,), name="NOVAC_FUNCTIONAL")

0 comments on commit 1eba068

Please sign in to comment.