Changes

Jump to navigation Jump to search
Line 38: Line 38:  
=== Site Model ===  
 
=== Site Model ===  
   −
Initially Moksaya project offers the following functionality to the site :
+
Initially Moksaya project offers a RESTful interface to the following models:
 +
User Profiles can be accessed by the RESTful Apis and it serves all the related Resources say all the projects of particular user , comments on projects, likes , friends of the user etcs.
   −
* Accounts : I have added an existing Django app to handle authentication and user accounts , I have made some modifications to include the User Profile functionality.It's not complete but it's functional so to give me an idea of what we are trying to achieve.
+
* Top Level View : http://127.0.0.1:8000/api/v1/profile/list/
   −
* Projects : This django app facilitates the site with the ability to Upload / Download and sharing of Projects along with the basic descriptions.This app also provides the comment functionality and I plan to extend this app to handle more functionalities like Forking , Galleries , Favourite , Like etcs.
+
  {
 +
    "meta": {
 +
        "limit": 20,
 +
        "next": null,
 +
        "offset": 0,
 +
        "previous": null,
 +
        "total_count": 3
 +
    },
 +
    "objects": [
 +
        {
 +
            "about_me": "DjangoNaut",
 +
            "birth_date": "1991-06-20",
 +
            "friends": [
 +
                "testuser",
 +
                "SomeDude"
 +
            ],
 +
            "gender": 1,
 +
            "language": "en",
 +
            "location": "India",
 +
            "mugshot": "/media/mugshots/d749832b7a.jpg",
 +
            "privacy": "registered",
 +
            "projects": [
 +
                {
 +
                    "Likes": 3,
 +
                    "comment": [
 +
                        {
 +
                            "entry": "Another story i am covering and i want to test the constrains this time",
 +
                            "resource_uri": "",
 +
                            "text": "MAhn this is some awesome shit "
 +
                        },
 +
                        {
 +
                            "entry": "Another story i am covering and i want to test the constrains this time",
 +
                            "resource_uri": "",
 +
                            "text": "cool Man comments are returned in APIs"
 +
                        }
 +
                    ],
 +
                    "desc": "here is another hack by me and I am doing this right now",
 +
                    "owner": "aregee",
 +
                    "screenshot": "/media/projects/Screenshot_from_2013-01-21_030756.png",
 +
                    "shared_date": "2013-06-25T18:48:18.205760",
 +
                    "src": "/media/proejcts/admin.py",
 +
                    "title": "Another story i am covering and i want to test the constrains this time"
 +
                },
 +
                {
 +
                    "Likes": 1,
 +
                    "comment": [],
 +
                    "desc": "Wired Hack ",
 +
                    "owner": "aregee",
 +
                    "screenshot": "/media/projects/background.png",
 +
                    "shared_date": "2013-06-26T05:59:48.445868",
 +
                    "src": "/media/proejcts/startconky.sh",
 +
                    "title": "Someting Wong"
 +
                },
 +
                {
 +
                    "Likes": 0,
 +
                    "comment": [],
 +
                    "desc": "This is my first hello world code",
 +
                    "owner": "aregee",
 +
                    "screenshot": "/media/projects/Screenshot_from_2013-02-03_173238.png",
 +
                    "shared_date": "2013-07-04T19:18:23.307241",
 +
                    "src": "/media/proejcts/hello.c",
 +
                    "title": "First Project Upload"
 +
                }
 +
            ],
 +
            "user": "aregee",
 +
            "website": "http://rahulgaur.info/"
 +
        },
 +
        {
 +
            "about_me": "Profile BIO",
 +
            "birth_date": "2013-06-26",
 +
            "friends": [
 +
                "aregee",
 +
                "SomeDude"
 +
            ],
 +
            "gender": 2,
 +
            "language": "en",
 +
            "location": "Delhi",
 +
            "mugshot": null,
 +
            "privacy": "registered",
 +
            "projects": [
 +
                {
 +
                    "Likes": 3,
 +
                    "comment": [],
 +
                    "desc": "This is my first hello world code",
 +
                    "owner": "testuser",
 +
                    "screenshot": "/media/projects/Screenshot_from_2013-02-03_173238.png",
 +
                    "shared_date": "2013-06-27T15:31:22.560494",
 +
                    "src": "/media/proejcts/hello.c",
 +
                    "title": "First Project Upload"
 +
                },
 +
                {
 +
                    "Likes": 0,
 +
                    "comment": [],
 +
                    "desc": "Wired Hack ",
 +
                    "owner": "testuser",
 +
                    "screenshot": "/media/projects/background.png",
 +
                    "shared_date": "2013-07-04T19:37:54.184572",
 +
                    "src": "/media/proejcts/startconky.sh",
 +
                    "title": "Someting Wong"
 +
                }
 +
            ],
 +
            "user": "testuser",
 +
            "website": "http://Something.com/"
 +
        },
 +
        {
 +
            "about_me": "Hello I am a dummy User here and I am doing something very amazing",
 +
            "birth_date": "2013-07-02",
 +
            "friends": [
 +
                "aregee",
 +
                "testuser"
 +
            ],
 +
            "gender": 1,
 +
            "language": "en",
 +
            "location": "India",
 +
            "mugshot": "/media/mugshots/0ebb9512eb.jpg",
 +
            "privacy": "registered",  
 +
            "projects": [],  
 +
            "user": "SomeDude",  
 +
            "website": "http://somedude.com/"
 +
        }
 +
    ]
 +
  }
   −
* Pinax_Theme_bootstrap : I have been customizing this django app to attain a desirable frontend , this app handles the User Interface Part.
+
* Individual User Profiles could be further requested as http://127.0.0.1:8000/api/v1/profile/list/2/?format=json
 +
  {
 +
    "about_me": "Profile BIO",
 +
    "birth_date": "2013-06-26",
 +
    "friends": [
 +
        "aregee",  
 +
        "SomeDude"
 +
    ],
 +
    "gender": 2,
 +
    "language": "en",
 +
    "location": "Delhi",
 +
    "mugshot": null,
 +
    "privacy": "registered",
 +
    "projects": [
 +
        {
 +
            "Likes": 3,
 +
            "comment": [],
 +
            "desc": "This is my first hello world code",
 +
            "owner": "testuser",
 +
            "screenshot": "/media/projects/Screenshot_from_2013-02-03_173238.png",
 +
            "shared_date": "2013-06-27T15:31:22.560494",
 +
            "src": "/media/proejcts/hello.c",
 +
            "title": "First Project Upload"
 +
        },
 +
        {
 +
            "Likes": 0,
 +
            "comment": [],
 +
            "desc": "Wired Hack ",
 +
            "owner": "testuser",
 +
            "screenshot": "/media/projects/background.png",
 +
            "shared_date": "2013-07-04T19:37:54.184572",
 +
            "src": "/media/proejcts/startconky.sh",
 +
            "title": "Someting Wong"
 +
        }
 +
    ],
 +
    "user": "testuser",
 +
    "website": "http://Something.com/"
 +
  }
    +
* Related Resource Projects here can be accessed by http://127.0.0.1:8000/api/v1/projects/?format=json
 +
  {
 +
    "meta": {
 +
        "limit": 20,
 +
        "next": null,
 +
        "offset": 0,
 +
        "previous": null,
 +
        "total_count": 5
 +
    },
 +
    "objects": [
 +
        {
 +
            "Likes": 3,
 +
            "comment": [
 +
                {
 +
                    "entry": "Another story i am covering and i want to test the constrains this time",
 +
                    "resource_uri": "",
 +
                    "text": "MAhn this is some awesome shit "
 +
                },
 +
                {
 +
                    "entry": "Another story i am covering and i want to test the constrains this time",
 +
                    "resource_uri": "",
 +
                    "text": "cool Man comments are returned in APIs"
 +
                }
 +
            ],
 +
            "desc": "here is another hack by me and I am doing this right now",
 +
            "owner": "aregee",
 +
            "screenshot": "/media/projects/Screenshot_from_2013-01-21_030756.png",
 +
            "shared_date": "2013-06-25T18:48:18.205760",
 +
            "src": "/media/proejcts/admin.py",
 +
            "title": "Another story i am covering and i want to test the constrains this time"
 +
        },
 +
        {
 +
            "Likes": 1,
 +
            "comment": [],
 +
            "desc": "Wired Hack ",
 +
            "owner": "aregee",
 +
            "screenshot": "/media/projects/background.png",
 +
            "shared_date": "2013-06-26T05:59:48.445868",
 +
            "src": "/media/proejcts/startconky.sh",
 +
            "title": "Someting Wong"
 +
        },
 +
        {
 +
            "Likes": 3,
 +
            "comment": [],
 +
            "desc": "This is my first hello world code",
 +
            "owner": "testuser",
 +
            "screenshot": "/media/projects/Screenshot_from_2013-02-03_173238.png",
 +
            "shared_date": "2013-06-27T15:31:22.560494",
 +
            "src": "/media/proejcts/hello.c",
 +
            "title": "First Project Upload"
 +
        },
 +
        {
 +
            "Likes": 0,
 +
            "comment": [],
 +
            "desc": "This is my first hello world code",
 +
            "owner": "aregee",
 +
            "screenshot": "/media/projects/Screenshot_from_2013-02-03_173238.png",
 +
            "shared_date": "2013-07-04T19:18:23.307241",
 +
            "src": "/media/proejcts/hello.c",
 +
            "title": "First Project Upload"
 +
        },
 +
        {
 +
            "Likes": 0,
 +
            "comment": [],
 +
            "desc": "Wired Hack ",
 +
            "owner": "testuser",
 +
            "screenshot": "/media/projects/background.png",
 +
            "shared_date": "2013-07-04T19:37:54.184572",
 +
            "src": "/media/proejcts/startconky.sh",
 +
            "title": "Someting Wong"
 +
        }
 +
    ]
 +
  }
 +
 
 +
In the above results I have excluded Project ids from the json Response, but similarly each individual project could be accessed and updated by making GET or Post or Put request to http://127.0.0.1:8000/api/v1/projects/<pk>?format=json
 +
 +
* Accessing particular  project http://127.0.0.1:8000/api/v1/projects/2/?format=json
 +
 +
  {
 +
    "Likes": 1,
 +
    "comment": [],
 +
    "desc": "Wired Hack ",
 +
    "owner": "aregee",
 +
    "screenshot": "/media/projects/background.png",
 +
    "shared_date": "2013-06-26T05:59:48.445868",
 +
    "src": "/media/proejcts/startconky.sh",
 +
    "title": "Someting Wong"
 +
}
 +
 +
==Forking==
 +
Lets take a look at how forking works here , though this is not really the best approach but I am doing this for understanding purpose and would figure out the proper solution for this ..
 +
but for now here it is.
 +
 +
* Lets say these are the projects on the Moksaya submitted by the user  :
 +
  {
 +
    "meta": {
 +
        "limit": 20,
 +
        "next": null,
 +
        "offset": 0,
 +
        "previous": null,
 +
        "total_count": 3
 +
    },
 +
    "objects": [
 +
        {
 +
            "Likes": 3,
 +
            "comment": [
 +
                {
 +
                    "entry": "Another story i am covering and i want to test the constrains this time",
 +
                    "resource_uri": "",
 +
                    "text": "MAhn this is some awesome shit "
 +
                },
 +
                {
 +
                    "entry": "Another story i am covering and i want to test the constrains this time",
 +
                    "resource_uri": "",
 +
                    "text": "cool Man comments are returned in APIs"
 +
                }
 +
            ],
 +
            "desc": "here is another hack by me and I am doing this right now",
 +
            "id": 1,
 +
            "owner": "aregee",
 +
            "screenshot": "/media/projects/Screenshot_from_2013-01-21_030756.png",
 +
            "shared_date": "2013-06-25T18:48:18.205760",
 +
            "src": "/media/proejcts/admin.py",
 +
            "title": "Another story i am covering and i want to test the constrains this time"
 +
        },
 +
        {
 +
            "Likes": 1,
 +
            "comment": [],
 +
            "desc": "Wired Hack ",
 +
            "id": 2,
 +
            "owner": "aregee",
 +
            "screenshot": "/media/projects/background.png",
 +
            "shared_date": "2013-06-26T05:59:48.445868",
 +
            "src": "/media/proejcts/startconky.sh",
 +
            "title": "Someting Wong"
 +
        },
 +
        {
 +
            "Likes": 3,
 +
            "comment": [],
 +
            "desc": "This is my first hello world code",
 +
            "id": 3,
 +
            "owner": "testuser",
 +
            "screenshot": "/media/projects/Screenshot_from_2013-02-03_173238.png",
 +
            "shared_date": "2013-06-27T15:31:22.560494",
 +
            "src": "/media/proejcts/hello.c",
 +
            "title": "First Project Upload"
 +
        }
 +
    ]
 +
  }
 +
 +
* Now I am logged in as aregee , and here is my profile at  127.0.0.1:8000/api/v1/profile/list/1/?format=json
 +
 +
  {
 +
    "about_me": "DjangoNaut",
 +
    "birth_date": "1991-06-20",
 +
    "friends": [
 +
        "testuser",
 +
        "SomeDude"
 +
    ],
 +
    "gender": 1,
 +
    "language": "en",
 +
    "location": "India",
 +
    "mugshot": "/media/mugshots/d749832b7a.jpg",
 +
    "privacy": "registered",
 +
    "projects": [
 +
        {
 +
            "Likes": 3,
 +
            "comment": [
 +
                {
 +
                    "entry": "Another story i am covering and i want to test the constrains this time",
 +
                    "resource_uri": "",
 +
                    "text": "MAhn this is some awesome shit "
 +
                },
 +
                {
 +
                    "entry": "Another story i am covering and i want to test the constrains this time",
 +
                    "resource_uri": "",
 +
                    "text": "cool Man comments are returned in APIs"
 +
                }
 +
            ],
 +
            "desc": "here is another hack by me and I am doing this right now",
 +
            "id": 1,
 +
            "owner": "aregee",
 +
            "screenshot": "/media/projects/Screenshot_from_2013-01-21_030756.png",
 +
            "shared_date": "2013-06-25T18:48:18.205760",
 +
            "src": "/media/proejcts/admin.py",
 +
            "title": "Another story i am covering and i want to test the constrains this time"
 +
        },
 +
        {
 +
            "Likes": 1,
 +
            "comment": [],
 +
            "desc": "Wired Hack ",
 +
            "id": 2,
 +
            "owner": "aregee",
 +
            "screenshot": "/media/projects/background.png",
 +
            "shared_date": "2013-06-26T05:59:48.445868",
 +
            "src": "/media/proejcts/startconky.sh",
 +
            "title": "Someting Wong"
 +
        }
 +
    ],
 +
    "user": "aregee",
 +
    "website": "http://rahulgaur.info/"
 +
  }
 +
 +
 +
* Now I want to fork the Project with id = 3 created by testuser , so I will make a GET request to 127.0.0.1:8000/api/v1/forking/3/?format=json
 +
  {
 +
    "Changes": {
 +
        "owner": "testuser",
 +
        "shared_date": "2013-06-27T15:31:22.560494"
 +
    },
 +
    "desc": "This is my first hello world code",
 +
    "resource_uri": "/api/v1/forking/3/",
 +
    "screenshot": "/media/projects/Screenshot_from_2013-02-03_173238.png",
 +
    "shared_date": "2013-06-27T15:31:22.560494",
 +
    "src": "/media/proejcts/hello.c",
 +
    "title": "First Project Upload"
 +
  }
 +
 +
The diffs / metadata could be viewed for the changes made , for instance here the response shows the original author of the project and the date it was shared
 +
 +
 +
* Lets take a look at my Profile again at 127.0.0.1:8000/api/v1/profile/list/1/?format=json
 +
  {
 +
    "about_me": "DjangoNaut",
 +
    "birth_date": "1991-06-20",
 +
    "friends": [
 +
        "testuser",
 +
        "SomeDude"
 +
    ],
 +
    "gender": 1,
 +
    "language": "en",
 +
    "location": "India",
 +
    "mugshot": "/media/mugshots/d749832b7a.jpg",
 +
    "privacy": "registered",
 +
    "projects": [
 +
        {
 +
            "Likes": 3,
 +
            "comment": [
 +
                {
 +
                    "entry": "Another story i am covering and i want to test the constrains this time",
 +
                    "resource_uri": "",
 +
                    "text": "MAhn this is some awesome shit "
 +
                },
 +
                {
 +
                    "entry": "Another story i am covering and i want to test the constrains this time",
 +
                    "resource_uri": "",
 +
                    "text": "cool Man comments are returned in APIs"
 +
                }
 +
            ],
 +
            "desc": "here is another hack by me and I am doing this right now",
 +
            "id": 1,
 +
            "owner": "aregee",
 +
            "screenshot": "/media/projects/Screenshot_from_2013-01-21_030756.png",
 +
            "shared_date": "2013-06-25T18:48:18.205760",
 +
            "src": "/media/proejcts/admin.py",
 +
            "title": "Another story i am covering and i want to test the constrains this time"
 +
        },
 +
        {
 +
            "Likes": 1,
 +
            "comment": [],
 +
            "desc": "Wired Hack ",
 +
            "id": 2,
 +
            "owner": "aregee",
 +
            "screenshot": "/media/projects/background.png",
 +
            "shared_date": "2013-06-26T05:59:48.445868",
 +
            "src": "/media/proejcts/startconky.sh",
 +
            "title": "Someting Wong"
 +
        },
 +
        {
 +
            "Likes": 0,
 +
            "comment": [],
 +
            "desc": "This is my first hello world code",
 +
            "id": 4,
 +
            "owner": "aregee",
 +
            "screenshot": "/media/projects/Screenshot_from_2013-02-03_173238.png",
 +
            "shared_date": "2013-07-04T20:46:43.062294",
 +
            "src": "/media/proejcts/hello.c",
 +
            "title": "First Project Upload"
 +
        }
 +
    ],
 +
    "user": "aregee",
 +
    "website": "http://rahulgaur.info/"
 +
  }
 +
 +
 +
* And the list of projects at 127.0.0.1:8000/api/v1/projects/
 +
 +
  {
 +
    "meta": {
 +
        "limit": 20,
 +
        "next": null,
 +
        "offset": 0,
 +
        "previous": null,
 +
        "total_count": 4
 +
    },
 +
    "objects": [
 +
        {
 +
            "Likes": 3,
 +
            "comment": [
 +
                {
 +
                    "entry": "Another story i am covering and i want to test the constrains this time",
 +
                    "resource_uri": "",
 +
                    "text": "MAhn this is some awesome shit "
 +
                },
 +
                {
 +
                    "entry": "Another story i am covering and i want to test the constrains this time",
 +
                    "resource_uri": "",
 +
                    "text": "cool Man comments are returned in APIs"
 +
                }
 +
            ],
 +
            "desc": "here is another hack by me and I am doing this right now",
 +
            "id": 1,
 +
            "owner": "aregee",
 +
            "screenshot": "/media/projects/Screenshot_from_2013-01-21_030756.png",
 +
            "shared_date": "2013-06-25T18:48:18.205760",
 +
            "src": "/media/proejcts/admin.py",
 +
            "title": "Another story i am covering and i want to test the constrains this time"
 +
        },
 +
        {
 +
            "Likes": 1,
 +
            "comment": [],
 +
            "desc": "Wired Hack ",
 +
            "id": 2,
 +
            "owner": "aregee",
 +
            "screenshot": "/media/projects/background.png",
 +
            "shared_date": "2013-06-26T05:59:48.445868",
 +
            "src": "/media/proejcts/startconky.sh",
 +
            "title": "Someting Wong"
 +
        },
 +
        {
 +
            "Likes": 3,
 +
            "comment": [],
 +
            "desc": "This is my first hello world code",
 +
            "id": 3,
 +
            "owner": "testuser",
 +
            "screenshot": "/media/projects/Screenshot_from_2013-02-03_173238.png",
 +
            "shared_date": "2013-06-27T15:31:22.560494",
 +
            "src": "/media/proejcts/hello.c",
 +
            "title": "First Project Upload"
 +
        },
 +
        {
 +
            "Likes": 0,
 +
            "comment": [],
 +
            "desc": "This is my first hello world code",
 +
            "id": 4,
 +
            "owner": "aregee",
 +
            "screenshot": "/media/projects/Screenshot_from_2013-02-03_173238.png",
 +
            "shared_date": "2013-07-04T20:46:43.062294",
 +
            "src": "/media/proejcts/hello.c",
 +
            "title": "First Project Upload"
 +
        }
 +
    ]
 +
  }
 +
 +
 +
Difference among the two Projects can be tracked by  Project.objects.get(pk = 4).diff(Project.objects.get(pk = 3))  , its a method provided by the django-forkit app to view changes / differences in the forkable models.
 +
Meta data field needs to bee added to Projects field so that we can save these differences when a project is forked , and every project should contain a link to original creator.
    
=== TODOS ===  
 
=== TODOS ===  
25

edits

Navigation menu