Permalink
Browse files

working on category creation from likes page

  • Loading branch information...
1 parent 02bd124 commit a514a8e97aa03c6b0d5963bdc149b87d2f46b216 @friendofrobots committed May 21, 2011
View
No changes.
@@ -5,12 +5,9 @@
url(r'^likes/$', 'likes', name='likes'),
url(r'^likes/(\S+)/$', 'likes', name='likes_start'),
url(r'^likes/(\S+)/(\d+)$', 'likes', name='likes_page'),
- url(r'^pmis/(\d+)$', 'like_pmis', name='like_pmis'),
- url(r'^category/add/(\w+)$', 'addSeed', name='addSeed'),
- url(r'^category/delete/(\w+)$', 'deleteSeed', name='deleteSeed'),
- url(r'^category/status/$', 'categoryStatus', name='categoryStatus'),
url(r'^category/$', 'categories', name='categories'),
url(r'^category/(\d+)$', 'category', name='category'),
url(r'^category/(\d+)/(\d+)$', 'category', name='category_page'),
+ url(r'^download/$', 'download', name='download'),
url(r'^$', 'home', name='home'),
)
@@ -5,7 +5,8 @@
from django.core.paginator import Paginator, InvalidPage, EmptyPage
from django.shortcuts import get_object_or_404, redirect
import json
-from toolkit.models import Entity, Link, PMI
+from toolkit.models import Entity, Link, PMI, Category, CategoryScore
+from toolkit.forms import CategoryCreateForm
from toolkit import tasks
from celery.result import AsyncResult
@@ -24,6 +25,18 @@ def home(request, template_name="air_explorer/home.html"):
'ready' : ready,
}, context_instance=RequestContext(request))
+def download(request, template_name="air_explorer/download.html"):
+ if request.user.is_authenticated():
+ try:
+ stage = request.user.profile.downloadStatus.stage
+ except:
+ stage = None
+ else:
+ return redirect('home')
+ return render_to_response(template_name, {
+ "stage" : stage,
+ }, context_instance=RequestContext(request))
+
def friends(request, template_name="air_explorer/friends.html"):
if request.user.is_authenticated():
friends = Entity.objects.filter(owner=request.user.profile,linksFrom__relation="likes").distinct()
@@ -56,91 +69,35 @@ def likes(request, startsWith=None, page=1, template_name="air_explorer/likes.ht
like_page = paginator.page(page)
except (EmptyPage, InvalidPage):
like_page = paginator.page(paginator.num_pages)
-
+
if request.method == 'POST':
try:
category = profile.activeCategory
+ createForm = CategoryCreateForm({ 'id':category.id })
+ # should probably throw some sort of error here too...
except:
category = Category.objects.create(owner=profile,
name=request.POST.get('name','tempcategoryname'),
active=profile)
if category.name == 'tempcategoryname':
- category.name = 'category'+str(category.id)
+ category.name = 'Category '+str(category.id)
category.save()
else:
- category = None
+ try:
+ category = profile.activeCategory
+ createForm = CategoryCreateForm(initial={'category_id':category.id})
+ except:
+ category = None
+ createForm = None
return render_to_response(template_name, {
'startsWith': startsWith,
'likes' : like_page,
'category' : category,
+ 'createForm' : createForm,
}, context_instance=RequestContext(request))
else:
return redirect('home')
-def like_pmis(request, like_id):
- if request.user.is_authenticated():
- profile = request.user.profile
- like = get_object_or_404(Entity,id=like_id)
- response_data = {
- "pmis": [[pmi.fromEntity.name,pmi.value] if pmi.toEntity == like else [pmi.toEntity.name,pmi.value] for pmi in like.getpmis()]
- }
- else:
- response_data = {
- "error": "user must be logged in"
- }
- return HttpResponse(json.dumps(response_data),mimetype="application/json")
-
-def addSeed(request, seed_id):
- if request.user.is_authenticated():
- if request.method == 'POST':
- profile = request.user.profile
- if profile.activeCategory:
- seed = Entity.objects.get(id=seed_id)
- profile.activeCategory.seeds.add(seed)
- response_datat = {
- "id":seed_id,
- "name":name,
- }
- else:
- response_data = {
- "error":"start a category first"
- }
- else:
- response_data = {
- "error": "must be a post request"
- }
- else:
- response_data = {
- "error": "user must be logged in"
- }
- return HttpResponse(json.dumps(response_data),mimetype="application/json")
-
-def deleteSeed(request, seed_id):
- if request.user.is_authenticated():
- if request.method == 'POST':
- profile = request.user.profile
- try:
- active = profile.activeCategory
- seed = Entity.objects.get(id=seed_id)
- active.seeds.remove(seed)
- response_data = {
- "id":seed_id,
- "name":name,
- }
- except:
- response_data = {
- "error":"start a category first"
- }
- else:
- response_data = {
- "error": "must be a post request"
- }
- else:
- response_data = {
- "error": "user must be logged in"
- }
- return HttpResponse(json.dumps(response_data),mimetype="application/json")
-
def categories(request, template_name="air_explorer/categories.html"):
if request.user.is_authenticated():
profile = request.user.profile
@@ -187,32 +144,3 @@ def category(request, category_id, page=1, template_name="air_explorer/category.
'category' : category,
'scores' : score_page,
}, context_instance=RequestContext(request))
-
-def categoryStatus(request):
- if request.user.is_authenticated():
- profile = request.user.profile
- try:
- if profile.activeCategory.task_id:
- result = AsyncResult(status.task_id)
- response_data = {
- "stage":1,
- "state": result.state,
- "id": profile.activeCategory.id,
- "name": profile.activeCategory.name,
- }
- else:
- response_data = {
- "stage":2,
- "state": "completed",
- "id": profile.activeCategory.id,
- "name": profile.activeCategory.name,
- }
- except:
- response_data = {
- "error" : "no active category"
- }
- else:
- response_data = {
- "error": "user must be logged in"
- }
- return HttpResponse(json.dumps(response_data), mimetype="application/json")
View
@@ -2,6 +2,6 @@
urlpatterns = patterns('fbauth.views',
url(r'^logout/$', 'fblogout', name='logout'),
- url(r'^login/$', 'fblogin', {'redirect':'/'}, name='login' ),
+ url(r'^login/(\S+)$', 'fblogin', name='login_redirect'),
url(r'^login/$', 'fblogin', name='login'),
)
View
@@ -12,7 +12,7 @@
authorize_url = 'https://graph.facebook.com/oauth/authorize'
access_token_url = 'https://graph.facebook.com/oauth/access_token'
-def fblogin(request, redirect='/'):
+def fblogin(request, redirectTo='home'):
args = dict(client_id=settings.FB_ID,
redirect_uri='http://'+request.get_host()+request.path,
)
@@ -50,7 +50,7 @@ def fblogin(request, redirect='/'):
password=access_token)
login(request, user)
- return HttpResponseRedirect(redirect)
+ return redirect(redirectTo)
elif request.GET.__contains__("error"):
raise Exception("got an error from facebook")
return render_to_response("fbauth/login.html", {
@@ -109,6 +109,7 @@ a {
font-size: 200%;
background-color: #DDD;
padding: 4px;
+ margin-top: 4px;
}
#likes {
@@ -117,8 +118,9 @@ a {
.like {
width:100px;
+ height:140px;
float:left;
- margin: 2px;
+ margin: 2px 6px;
border: 1px solid #B3B3B3;
overflow:hidden;
}
@@ -129,9 +131,10 @@ a {
}
.title-holder {
- font-size:10pt;
+ font-size:70%;
text-align:center;
height: 30px;
+ padding: 4px;
}
#rename {
@@ -147,10 +150,14 @@ a {
}
#nav {
- margin:10px;
+ margin:20px 25px 10px 0;
+ float: right;
+ border: 2px solid #41759F;
+ padding: 4px 10px;
}
#nav a {
- text-decoration:underline;
+ font-weight:bold;
+ color: #000;
}
#category {
@@ -161,21 +168,22 @@ a {
left: 5px;
}
-.category h2 {
+.category h3 {
margin:4px;
- font-size:100%;
font-weight: normal;
- background-color: #DDD;
+ background-color: #EEE;
padding: 4px;
+ border-top: 1px solid #CCC;
}
.filter {
display : none;
background-color : rgba(255,255,255,0.9);
- position: absolute;
+ position: relative;
+ bottom: 140px;
z-index:10;
width:102px;
- height:140px;
+ height:144px;
}
#profile_img {
@@ -4,9 +4,26 @@ body {
font-family: sans-serif;
}
+ul {
+ list-style-type: none;
+ margin:4px;
+ padding:0;
+}
+
+button, .button {
+ border: 2px solid #000;
+ border-radius: 12px;
+ background-color: #FFF;
+ font-weight: bold;
+ cursor: pointer;
+}
+button:hover, .button:hover {
+ background-color: #CCC;
+}
+
#header {
width:100%;
- border-bottom: 2px solid black;
+ bottom: 2px solid black;
margin: 0;
padding: 0;
}
@@ -44,12 +61,6 @@ body {
font-weight:bold;
}
-ul {
- list-style-type: none;
- margin:4px;
- padding:0;
-}
-
/* pmis */
.pmis {
display:none;
@@ -58,11 +69,13 @@ ul {
.add-seed {
font-size: 50%;
color: #00FF00;
+ cursor: pointer;
}
.delete-seed {
font-size: 50%;
color: #FF0000;
+ cursor: pointer;
}
.seed-id {
@@ -71,8 +84,47 @@ ul {
#category {
border : 2px solid black;
- width: 200px;
+ width: 250px;
position: fixed;
- top: 40px;
+ top: 100px;
left: 5px;
+ padding: 10px;
+}
+
+#category h2 {
+ text-align: center;
+ margin: 4px;
+}
+
+#creation-options {
+ display:none;
+ font-size:75%;
+}
+#creation-options li:first-child {
+ display:none;
+}
+#creation-options li {
+ padding: 3px;
+}
+#creation-options label {
+ float:left;
+ text-align:right;
+ width:80px;
+ display:block;
+ margin: 0 0 5px 0;
+ padding: 3px 5px;
+}
+#creation-options .floatField {
+ padding:1px 3px;
+ text-align: right;
+}
+#category fieldset {
+ border-width:1px 0 0 0;
+}
+#category legend {
+ font-size:80%;
+ cursor: pointer;
+}
+#category-done {
+ text-align: right;
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.

0 comments on commit a514a8e

Please sign in to comment.