Thursday, May 26, 2011

GSoC 2011 Melange Testing Project : Coding Period Week 1


The coding period has officially started and I have been rather slow and falling behind the schedule. I still have not started writing a test but I will try to give more time to the project in a couple of days. 
    It was quite an eventful week. I have been waiting for the welcome package by google and it was already May 23, so I just asked on the GSoC students mailing lists if anyone has already received it. Some of the students were very furious about starting such a thread as Carol had stated the deadline to be May 27. What I believed was that its not necessary that everyone will receive the package after 23. I also made a remark of why he bothered to read and reply if he was not interested. I was surprised to see that only one or two previous GSoC students from the 4k members strong mailing list care to answer constructively. It was encouraging to read Phillip Herron's comment which I quote below:

"Just be patient they _will_ come from last years GSoC it just takes
time if you consider the fact they have to individually create like 1000
of these things and get them each shipped to each of our address's
just be patient. Its a great feeling when it comes :) "


This is the reason why I love Melange. You are never restricted but re-directed if you are going wrong. I still remember when Mario told me that its bad collaboration when I commented a little offensively on the efforts of an aspiring student during the pre-GSoC time. I am also amazed by Carol's patience at answering the same  set of questions again and again asked by students on the gsoc mailing list. Anyway, I learnt from the criticism that I should be patient and keep good relations and collaboration with fellow students.

    I am going slow at the project and falling behind the schedule. I have not written a single line of usable code till now. My project is concerned with writing tests for the logic and views  and as I stated in my last post that I shall start with app.soc.logic modules, so I have generated a directory structure of app.soc.logic which is basically a tree like structure of the files in the directory. All the previous tests have been moved into tests/old_app directory as they conflicted with the new framework. My aim is to re-use the old tests and make the necessary changes with respect to the new framework. I will start with the app.soc.logic.allocations.py  module.

    I had a meeting with my mentor Leo yesterday i.e. on 25 May '11 and I discussed with him a few concepts related to testing.I asked hime what should the basic approach be while attempting to write the tests. Basically, we should first understand what a specific function does, think about all its use cases and then we test each of the use cases.
   I also have to implement a view to run the tests online rather than running the tests locally. I did not exactly know how to implement this. But Leo suggested that there are already some open source projects like gaeunit which do that. So, I referred to the gaeunit project and its just a single module which implements that. My approach was to run the tests using the python environment of GAE and somehow capture the test results but there is already a TestResult class in unittest module which returns an object for such manipulation. So, I need to make use of this class and tasks to implement my view.
   So, my goal for this week is to write the view and implement the test for app.soc.logic.allocations.py module at least.

 

GSoC 2011 GUI Overhaul Project: Start Coding

Hi everyone, sorry for my late post :). In this post I'll talk about what things have been done by me to accomplish my project. A week ago I had conference with Carol and Daniel. We were talked about what admin, Carol, needs to improve the usability of administration dashboard. Actually before the meeting, I've been working to add breadcrumb and refactor melange.map.js. So, I'll talk about the breadcrumb and melange.map.js first. If you don't have an idea what breadcrumb looked alike, take a look at the following picture.

The breadcrumb is something like path navigation that shows site hierarchy. Jacob Nielsen has a nice written summary of why breadcrumb navigation increasingly useful. I thought that the way breadcrumb rendered would be the same as Header, Footer or MainMenu in base_templates.py. My first thought was not so good. I defined a global map of named URL patterns with theirs hierarchies, something like this one :

...
BREADCRUMB = {
'gsoc_homepage': {
'name': 'Home',
'parents': [],
'url': 'homepage'
},
'search_gsoc': {
'name': 'Search',
'parents': ['gsoc_homepage'],
'url': 'searchpage'
},
'gsoc_accepted_orgs': {
'name': 'Accepted Organizations',
'parents': ['gsoc_homepage'],
'url': 'allProjects'
},
'edit_gsoc_profile': {
'name': 'My Profile',
'parents': ['gsoc_homepage']
},
'create_gsoc_profile': {
'name': 'My Profile',
'parents': ['gsoc_homepage']
},
'gsoc_dashboard': {
'name': 'My Dashboard',
'parents': ['gsoc_homepage']
},
'gsoc_tax_form': {
'name': 'Tax Form',
'parents': ['gsoc_homepage', 'gsoc_dashboard']
},
'gsoc_enrollment_form': {
'name': 'Enrollment form',
'parents': ['gsoc_homepage', 'gsoc_dashboard']
},
'gsoc_admin_dashboard': {
'name': 'Admin Dashboard',
'parents': ['gsoc_homepage']
},
'lookup_gsoc_profile': {
'name': 'Lookup profile',
'parents': ['gsoc_homepage', 'gsoc_admin_dashboard']
}
}

...

class Breadcrumb(Template):
"""Breadcrumb template
"""

def __init__(self, data, current_view):
self.data = data
self.current_view = current_view

def context(self):
"""breadcrumb_path context will hold breadcrumb path of current view
which consists list of tuples containg page_name and url
"""

from django.core.urlresolvers import reverse
context = {'breadcrumb_path': []}
for view in self.current_view:
if BREADCRUMB.get(view, None):
for parent in BREADCRUMB[view]['parents']:
if BREADCRUMB.get(parent, None):
href = None
if BREADCRUMB.get(parent).get('url'):
func =
self.data.redirect.__getattribute__(BREADCRUMB[parent]['url'])
href = func().url()
elif self.data.profile:
href = self.data.redirect.urlOf(parent)

context['breadcrumb_path'].append((BREADCRUMB[parent]['name'], href,))
context['breadcrumb_path'].append((BREADCRUMB[view]['name'], None,))
break

return context

def templatePath(self):
return "v2/modules/gsoc/breadcrumb.html"

...


Sverre suggested me avoid the global map, and define a method that returns the breadcrumb navigation, more or less like this one :

class ProfilePage(RequestHandler):
"""View for the participant profile.
"""

parentView(self):
return (self.redirect.urlOf('homepage'), "Home")


I agree with Sverre's suggestion, I'll refactor my code :).

After the breadcrumb, I also plan to refactor melange.map.js and combine the map in profile.js into one. All map functionalities should be placed into melange.map.js. I've worked on the profile_readonly.js before. Basically profile.js and profile_readonly.js have the same code, except the event handler to update the marker was removed in profile_readonly.js. As you may see, every time I need a map on page, I create a mypage_with_map.js and copy the code from profile.js or melange.map.js, hack a little bit to suit the need and tadda I betray the DRY principle. That's why we need to refactor the melange.map.js. The MAP API also need to be updated to v3, same as the map we see in organization homepage.

Back again to our discussion with Carol. Here's what I noted after the meeting :
  • If we're login as a host and view the dashboard (My Dashboard), we will see the page overloaded by Jqgrid list. Carol wants the list is grouped. Akeda has suggestion to group the list by tabs.
  • When students with project announced, there might be a student consider himself ineligible to participate. If Carol rejects that student, there will be available slot to accept another student that already rejected. Carol needs this feature to withdraw / accept student in her dashboard.
  • Carol needs the Admin dashboard to be enhanced.

My first thought was Carol wants the Dashboard ("My Dashboard" I think) need to be cleaned up, since it contains a lot of list components. So far I am working with the data from seed_db and didn't realize that in the live instance might contains hundred of entities. I posted my mockup with the tabs in milist :

Wednesday, May 25, 2011

GCI 2011 GCI with New Architecture: Beginning of the coding phase

The coding phase has finally begun and I started my project with the GCI Profile model.Currently, GCI has a different notification system where a user X can subscribe to the notification to a particular task by clicking a star on the task and can un-subscribe the task by clicking on the same star again, org_admin,mentor and the student claiming are automatically subscribed. In addition to this, we will now have Profile based notification settings where a user will be given an option to whether subscribe for the notifications automatically or not, for example a student at the time of profile creation can check/uncheck automatically subscribe to tasks I claim.The same can be applied for mentor and org_admin.The GCIStudentInfo model having the following additional fields specific to GCI was written next, number_of_tasks_completed , consent_form, student_id_form, grade.

The next step was to convert the roles itself.Basically for each student,mentor or org_admin entity I had to create a GCIProfile.And then I had to update all these references in the models containing them. I have used deferred library which lets us retrieve entites in batches and update their references easily.

My wiki page is at [0] and my instance is at [1]
[0] : http://code.google.com/p/soc/wiki/GCINewArchitectureGSoC2011
[1] : http://melange-slingshot316.appspot.com/

Tuesday, May 24, 2011

Week before the coding phase

I am very late on this particular blogpost, apologies for that.A week prior to the coding phase, I was working on asynchronous file uploads (for the student forms), I have used the jquery-fileupload plugin for this task and I have some problem with sending the request and so will look into it sometime later.But in this process, I have learnt how to add any javascript files to Melange and as for this, I first had to put the plugin file in app.jquery and add it's corresponding entry in soc.content.melange-dependency and run bin/paver closure to create minified version of it.I learnt that doing all that logic inside the function in the dependency array is not really the way it is meant to be.Ideally, one should create all the logic for a form in a template which is called using the tc() facility[0], which loads the javascript
template file and put variables (for example an id called #foo) in the context of the template as we can get the variables in the context (after we use the tc() facility in the django template) by using var _self = this; and then _self.context..I also learnt that Whenever we put a "null" in the array, LAB.js will wait for the above scripts to be downloaded, evaluated and ran before evaluating and then run the others.My mentor Madhusudhan gave me a lot of support and taught me many new things and thanks to Mario for advice on using javascript in Melange.

[0] http://code.google.com/p/soc/wiki/JavascriptCSSDependencies

GSoC 2011 GCI with New Architecture: Week before the coding phase

I am very late on this particular blogpost, apologies for that.A week prior to the coding phase, I was working on asynchronous file uploads (for the student forms), I have used the jquery-fileupload plugin for this task and I have some problem with sending the request and so will look into it sometime later.But in this process, I have learnt how to add any javascript files to Melange and as for this, I first had to put the plugin file in app.jquery and add it's corresponding entry in soc.content.melange-dependency and run bin/paver closure to create minified version of it.I learnt that doing all that logic inside the function in the dependency array is not really the way it is meant to be.Ideally, one should create all the logic for a form in a template which is called using the tc() facility[0], which loads the javascript
template file and put variables (for example an id called #foo) in the context of the template as we can get the variables in the context (after we use the tc() facility in the django template) by using var _self = this; and then _self.context..I also learnt that Whenever we put a "null" in the array, LAB.js will wait for the above scripts to be downloaded, evaluated and ran before evaluating and then run the others.My mentor Madhusudhan gave me a lot of support and taught me many new things and thanks to Mario for advice on using javascript in Melange.

[0] http://code.google.com/p/soc/wiki/JavascriptCSSDependencies