Discussion:
[Mayan EDMS: 2174] Metadata values, how to harness them
Lin Pro
2017-10-25 04:20:05 UTC
Permalink
How do you harness the lookup function when there is 10,000 values for a metadata type?
I am clueless where to store the values and how to present them as options.

Thanks for help
Regards
Lin
--
---
You received this message because you are subscribed to the Google Groups "Mayan EDMS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mayan-edms+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jonathon Exley
2017-10-25 07:49:28 UTC
Permalink
Can you give an example?
In not sure I understand what you are trying to do.

Jonathon.
Post by Lin Pro
How do you harness the lookup function when there is 10,000 values for a metadata type?
I am clueless where to store the values and how to present them as options.
Thanks for help
Regards
Lin
--
---
You received this message because you are subscribed to the Google Groups
"Mayan EDMS" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "Mayan EDMS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mayan-edms+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Lin Pro
2017-10-25 15:32:41 UTC
Permalink
Post by Jonathon Exley
Can you give an example?
Jonathon.
Hi,

For example how to use this info :
"Enter a template to render. Must result in a comma delimited string. Use
Django's default templating language
(https://docs.djangoproject.com/en/1.7/ref/templates/builtins/). Available
template context variables: {{ groups }} = "All the groups." {{ users }} =
"All the users."

The above help text is for metadata lookup table. The only thing I came up
with is to enter a comma separated values of the metadata, like so: 'John
Doe','Mark Doe','Jane Doe'
Which results in a dropdown selection available when I need to upload a
document with "required" metadata type. But my imagination stops here :-).
How will one manage the lookup table if there is 10,000 options to be shown?

I guess there is a template language that allows to point to a file on the
disk from which to pick those values?

The page for built-in tags and filters is of little help here:
Built-in template tags and filters
Built-in tag reference
autoescape
block
comment
csrf_token
cycle
...

Thank for hints
Regards
Lin
--
---
You received this message because you are subscribed to the Google Groups "Mayan EDMS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mayan-edms+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Lin Pro
2017-10-25 16:27:51 UTC
Permalink
On Wednesday, October 25, 2017 at 2:49:30 AM UTC-5, Jonathon wrote:
[...]

Hi Jonathon and the group. I found this:

===
Using the template system

Alternatively, you can use the Django template system to generate CSV. This
is lower-level than using the convenient Python csv module, but the
solution is presented here for completeness.

The idea here is to pass a list of items to your template, and have the
template output the commas in a for loop.

Here’s an example, which generates the same CSV file as above:

from django.http import HttpResponse
from django.template import loader, Context

def some_view(request):
# Create the HttpResponse object with the appropriate CSV header.
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment;
filename="somefilename.csv"'

# The data is hard-coded here, but you could load it from a database or
# some other source.
csv_data = (
('First row', 'Foo', 'Bar', 'Baz'),
('Second row', 'A', 'B', 'C', '"Testing"', "Here's a quote"),
)

t = loader.get_template('my_template_name.txt')
c = Context({
'data': csv_data,
})
response.write(t.render(c))
return response
The only difference between this example and the previous example is that
this one uses template loading instead of the CSV module. The rest of the
code – such as the content_type='text/csv' – is the same.

Then, create the template my_template_name.txt, with this template code:

{% for row in data %}"{{ row.0|addslashes }}", "{{ row.1|addslashes }}",
"{{ row.2|addslashes }}", "{{ row.3|addslashes }}", "{{ row.4|addslashes }}"
{% endfor %}
This template is quite basic. It just iterates over the given data and
displays a line of CSV for each row. It uses the addslashes template filter
to ensure there aren’t any problems with quotes.
====

It is out of my expetise to even try the solution. Is this the only way now?

Regards
Lin
--
---
You received this message because you are subscribed to the Google Groups "Mayan EDMS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mayan-edms+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...