Ok, the example from plugin birt helped me tons, but one question is bothering me, how can I pass params to the birt to select from id?
question | description
----------------------
1 | blabla
2 | xoxoxo
3 | tititi
4 | buhbuh
Example: I have this table above... From my grails application, I choose what question I want, so if I choose 1,3,4... The Birt report shows me selected only.
Basically, I have to change my dataset too, because my query is static and needed to be dynamic:.
...(query) and a1.question_id = 1 and a2.question_id = 2 and and a3.question_id = 3 (query)...
But in grails how I will pass the params to dataset?
the Birt report receives the parameters with params, you can use this part of code
def options = birtReportService.getRenderOption(request, 'html')
def result=birtReportService.runAndRender(reportName, params, options)
render result
. Remember don't forget place your rptdesing in a folder on (web-app)
Related
I want to run my perticular scenario or feature file more than one time.
Let's say if user enter 5 then i want my url to be hit 5 times.
is it possible in karate? Any help would be appreciated
Yes, read the docs: https://github.com/intuit/karate#loops
But also see example below using dynamic scenario outlines:
EDIT: using a Background will not work in Karate 1.3.0 onwards, please refer to this example: https://stackoverflow.com/a/75155712/143475
Background:
* def fun = function(i){ return { name: 'User ' + (i + 1) } }
* def data = karate.repeat(5, fun)
Scenario Outline:
* url 'http://httpbin.org/anything'
* request __row
* method post
Examples:
| data |
So run this, see how it works and study how it works as well.
Note that data driven features is an alternate approach where you can call a second feature file in a loop. So for example after using karate.repeat() 5 times like in the above Background, you use data as the argument to a second feature file that hits your url.
I am new to Django but I have experience in Rails.
In Rails, if you want to check what one of your action/function is doing, you can use the raise parameter.
The execution of the action will stop, and in http://locahost:3000 you can see the output of that function.
Example:
def answer:
#banana = 2 + 2
raise
end
If I reload localhost, a console opens and if I write #banana I get the result 4.
Is there something similar in Django?
There's pdb. You can check more here. On your code, you can do something like this:
def answer():
banana = 2 + 2
import pdb; pdb.set_trace()
return banana
Then on your terminal if you do banana you'll see the result of the sum.
I am learning grails using the definitive guide to grails 2 (using grails 2.3.7), and when I'm looking at the custom tag library it gives an example custom tag as follows:
def repeat = { attrs, body ->
int n = attrs.int('times)
n?.times { counter ->
out << body(counter +1)
}
}
so when I use this tag like so:
<g:repeat times="3">
Hello number ${it}<br>
</g:repeat>
I expect to get three separate lines on my rendered HTML:
Hello number 1
Hello number 2
Hello number 3
Instead I get:
hello number 1<br>hello number 2<br>hello number 3<br>
I have found methods that look like they should help, like decodeHTML() however I am thus unable to change the output that I want, and I'm not sure what I'm doing wrong.
I have tried doing:
out <<body.decodeHTML()
but I get a null pointer error...
That does not make sense unless there is something else in your taglib or something unusual in the GSP which is invoking the tag.
Does your taglib maybe have something like defaultEncodeAs='html' in it?
Use the tag like this:
<g:repeat times="3">
Hello number ${it}<br/>
</g:repeat>
HTML5 can render <br>, but it seems you are using version 4 or lower.
My question is just an extension of this thread [Question]http://stackoverflow.com/questions/851636/default-filter-in-django-admin .
from myproject.myapp.mymodels import fieldC
class Poll(models.Model):
fieldA = models.CharField(max_length=80, choices=CHOICES.MyCHOICES)
fieldB = models.ForeignKey(fieldC)
admin.py
list_display = ('fieldB__fieldc1')
Now my list filter shows four criteria All, A ,B ,C .
What I want is if the superuser is logged in ,the filter should show all four criteria All,A,B,C and if the user is other than superuser filter should only show All, A, B.
How can i acheive this ?
Here is my actual piece of admin.py
def changelist_view(self, request, extra_context=None):
referer = request.META.get('HTTP_REFERER', '')
test = referer.split(request.META['PATH_INFO'])
if test[-1] and not test[-1].startswith('?'):
if not request.GET.has_key('patient__patient_type__exact'):
q = request.GET.copy()
q['patient__patient_type__exact'] = 'Real'
request.GET = q
request.META['QUERY_STRING'] = request.GET.urlencode()
if not request.user.is_superuser:
q['patient__patient_type__exact'] = 'Real'
return super(VisitAdmin, self).changelist_view(request, extra_context)
Thanks in advance
I think the new FilterSpec API in Django 1.4 gives you exactly what you need here. Check out the docs on list_filter. In 1.4 you can now make custom list filters that subclass django.contrib.admin.SimpleListFilter and give you the power to write custom lookup and queryset code, and since the request is passed in you can do a simple conditional with is_superuser.
if request.user.is_superuser:
# pass one set of lookups
else:
# pass a different set
read the example code in the docs carefully and I think it will all be clear.
I'm reading a CSV file and one of the columns has text that contains symbols that is not recognized. After I read the file, symbols such as ' becomes � . I'm also saving this into a DB.
Obviously when I display this on a webpage, it shows garbage. How can I substitute HTML code (ex. ´ ;) for this with Grails?
I am reading the CSV using the csv plugin. Code below:
def f = "clientDocs/testfile.csv"
def fReader = new File(f).toCsvMapReader([batchSize:50, charset:'UTF-8'])
fReader.each { batchList ->
batchList.each {
def description = substituteSymbols(it.Description)
def substituteSymbols(inText) {
// HOW TO SUBSTITUTE HERE
}
Thanks for any help or suggestions. I've already tried string.replaceAll(regExp).
Grails comes with a basic set of encoders/decoders for common tasks.
What you want here is it.Description.encodeAsHTML().
And then if you want the original when displaying in the view, just reverse it with .decodeHTML()
You can read more about these here: http://grails.org/doc/latest/guide/single.html#codecs
(Edited decode method name typo as per the comment)