Changeset 983

Show
Ignore:
Timestamp:
11/16/08 13:22:27 (7 weeks ago)
Author:
lucy
Message:

quickrate fix, state constants changed from NONE to DRAFT

Location:
huginmunin/trunk/web/hm
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • huginmunin/trunk/web/hm/app/views/ext_api_views.py

    r958 r983  
    115115        if not objs: 
    116116            objs.extend(model.objects.filter(label__icontains=name)) # use search instead of icontains 
    117         if len(objs) < 10: 
     117        if len(objs) == 0: 
    118118            objs.extend(model.objects.filter(description__icontains=name)) # use search of icontains 
    119119        return objs 
     
    155155                        'node': ['label', 'description', 'type'], 
    156156                        'edge': ['label', 'description', 'parent', 'child'], 
    157                         'review': ['label', 'description', 'interest', 'node'] 
     157                        'review': ['label', 'description', 'interest', 'node'], 
     158                        'node_type_cast': [], 
     159                        'edge_type_cast': [], 
    158160                      } 
    159161 
     
    317319    if request.GET.has_key('callback'): 
    318320        callback = request.GET.__getitem__('callback') 
    319         json_data = { 'score': data['score'] or '', 'count': data['count'] or '' } 
     321        json_data = { 'score': data['score'] or '', 'count': data['count'] or '', 'customized': data['customized'] or '' } 
    320322        return json_response('%s(%s)' % (callback, json_data)) 
    321323    else: 
  • huginmunin/trunk/web/hm/app/views/quickrate_main.py

    r980 r983  
    1717 
    1818def index(request): 
    19     a = Action.objects.select_related().filter(item_type__model='behavior').exclude(user=current_user()) 
    20     b = a[random.randint(0, a.count())].item 
    21     if not b.dimension: 
    22         return HttpResponseRedirect(reverse('select_interest', args=(b.id,))) 
     19    if current_user().is_authenticated(): 
     20        a = Action.objects.select_related().filter(item_type__model='behavior').exclude(user=current_user()) 
    2321    else: 
    24         return HttpResponseRedirect(reverse('rate_review', args=(b.id,))) 
     22        a = Action.objects.select_related().filter(item_type__model='behavior') 
     23    if len(a) > 0: 
     24        b = a[random.randint(0, a.count())].item 
     25        if not b.dimension: 
     26            return HttpResponseRedirect(reverse('select_interest', args=(b.id,))) 
     27        else: 
     28            return HttpResponseRedirect(reverse('rate_review', args=(b.id,))) 
     29    else: 
     30        return render_response(request, 'quickrate/winner.html') 
    2531 
    2632def select_interest(request, review_id): 
  • huginmunin/trunk/web/hm/db/graph.py

    r963 r983  
    483483        """ 
    484484        try: 
    485             print "    make: label:%s dim:%s" % (label, dimension) 
    486485            r = Behavior.get(label=label, dimension=dimension, description=description, node=node) 
    487             print "ALREADY EXISTS %s" % r 
    488486            # TODO use find and then check if any hae same EdgeType 
    489487            raise AlreadyExists("Review %i already exists for %s, %s, %s, %s" % (r.id, r.label, r.dimension, r.description, r.node)) 
  • huginmunin/trunk/web/hm/db/state.py

    r963 r983  
    55 
    66import utils 
    7 import graph, citation 
     7import graph, citation, user, tag, rating 
    88 
    99""" 
     
    3030    @cvar STATEFUL_MODELS: 
    3131     
    32     @cvar NONE: 
    33     @cvar VISIBLE: 
    34     @cvar REMOVED: 
     32    @cvar DRAFT: eg, added by mechanical crawler, or is a test or in-progress addition 
     33    @cvar VISIBLE: visible on the main site and all that 
     34    @cvar REMOVED: deleted...but present just in case. these might get flushed periodically? 
    3535    """ 
    3636     
    3737    STATEFUL_MODELS = [ 
    38         graph.Node, graph.Edge, graph.Argument, #graph.BehaviorArgumentLink,  
    39         graph.Dimension, graph.Behavior, graph.UPC, 
    40         citation.Source, citation.Author, citation.Article, citation.Citation ] 
     38        graph.Node, graph.NodeType, graph.NodeTypeCast, 
     39        graph.Edge, graph.EdgeType, graph.EdgeTypeCast, 
     40        graph.Argument, graph.Dimension, graph.Behavior, graph.UPC, 
     41        citation.Source, citation.Author, citation.Article, citation.Citation, 
     42        tag.Tag, tag.Tagging, 
     43        #rating.Rating, ?? should we 
     44        user.UserInterestPercent] 
    4145     
    4246    @classmethod 
     
    6569         
    6670    # Valid States 
    67     NONE = 0 
     71    DRAFT = 0 
    6872    VISIBLE = 1 
    6973    REMOVED = 2