[p2pu-dev] Only challenges come up in Learn page

Dirk Uys dirk at p2pu.org
Mon Jun 25 12:05:15 UTC 2012


Cool, the project view is quite messy. I think most of the filtering
happens in learn(
https://github.com/p2pu/lernanta/blob/master/lernanta/apps/projects/views.py#L48
)

One thing that we should reduce is the amount of logic in the views. Views
should have some logic about the flow of interaction, currently we can't
change a field name in a model without lots of repercussions.

The right way to implement learn would be to write a custom Manager and
Queryset classes that return a list of projects according to tags. Then the
view can do something like

Projects.objects.get_project_with_tags(['learn', 'python',
'moon']).get_active().get_language('en')

I've read a few articles that describes the above. Here's one:
http://dabapps.com/blog/higher-level-query-api-django-orm/

This may be overkill, and a simple function taking the QuerySet as a
parameter and returning a new QuerySet is also good. Then the usage becomes:

tag_filtered = get_projects_with_tags(Project.objects.all, ['list', 'of',
'tags'])
active_projects = get_active_projects(tag_filtered)
lang_projects = get_language_projects('en')

You loose the chainability, but you skip the boilerplate classes.

Your thoughts?

Cheers
d

On Mon, Jun 25, 2012 at 1:38 PM, Jos Flores <josmasflores at gmail.com> wrote:

> Trying to track down where the filtering happens... I'm sorry to say
> this but my head is spinning while reading the projects view/model (I
> know you didn't write it). A fix that should be two minutes is taking
> ages cause there are so many side effects that can be triggered, and
> they all have to be tested :S
>
> I'm writing tests and separating stuff around; hope you are OK with that :)
>
> cheers,
> Jose
>
>
> On 25 June 2012 12:29, Dirk Uys <dirk at p2pu.org> wrote:
> > Hi Jose
> >
> > I think that all types of courses should show up. The learning style for
> a
> > course shouldn't affect the listing.
> >
> > Thanks!
> > d
> >
> > On Mon, Jun 25, 2012 at 1:20 PM, Jos Flores <josmasflores at gmail.com>
> wrote:
> >>
> >> Hi guys, is there a reason to show only 'Challenges' in the learn
> >> page? or is it a 'feature'?
> >>
> >> I am working on fixing the tags issue, but although now the count is
> >> correct, for some reason only challenges are displayed, and that makes
> >> the numbers wrong again.
> >>
> >> cheers,
> >> Jose
> >> _______________________________________________
> >> p2pu-dev mailing list
> >> p2pu-dev at lists.p2pu.org
> >> http://lists.p2pu.org/mailman/listinfo/p2pu-dev
> >
> >
> >
> > _______________________________________________
> > p2pu-dev mailing list
> > p2pu-dev at lists.p2pu.org
> > http://lists.p2pu.org/mailman/listinfo/p2pu-dev
> >
> _______________________________________________
> p2pu-dev mailing list
> p2pu-dev at lists.p2pu.org
> http://lists.p2pu.org/mailman/listinfo/p2pu-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p2pu.org/pipermail/p2pu-dev/attachments/20120625/933d0197/attachment.html>


More information about the p2pu-dev mailing list