Esempio n. 1
0
def view_territoire(request, id):
    articles = requests.get(BASE_URL + '/api/place/' + str(id) + '/capsules/',
                            headers=get_header(request)).json()

    territoires = requests.get(BASE_URL + '/api/place/',
                               headers=get_header(request))
    territoires = [Place(place) for place in territoires.json()]
    get_category = [1, 2, 3, 4]
    paginator = Paginator(articles, 6)
    page = request.GET.get('page', 1)
    try:
        article_page = paginator.page(page)
    except PageNotAnInteger:
        article_page = paginator.page(1)
    except EmptyPage:
        article_page = paginator.page(paginator.num_pages)

    territoire = requests.get(BASE_URL + '/api/place/' + str(id) + '/',
                              headers=get_header(request))
    territoire = territoire.json()
    return render(
        request, 'blog/view_territoire.html', {
            'articles': article_page,
            'territoires': territoires,
            'categories': get_category,
            'request_territoire': territoire['name'],
            'territoire_id': id
        })
Esempio n. 2
0
def upload(request):
    places = [
        Place(place)
        for place in requests.get(BASE_URL + '/api/place/').json()
    ]
    url = BASE_URL
    return render(request, 'blog/upload/upload.html', locals())
Esempio n. 3
0
def home(request):
    articles = requests.get(BASE_URL + '/api/capsule/last/')
    articles = articles.json()

    data = requests.get(BASE_URL + '/api/cpops_last/').json()

    get_territoire = requests.get(BASE_URL + '/api/place/',
                                  headers=get_header(request))
    get_territoire = [Place(place) for place in get_territoire.json()]

    get_category = [1, 2, 3, 4]  # Category.objects.all()
    allArticle = requests.get(BASE_URL + '/api/capsule/')
    allArticle = [Capsule(article) for article in allArticle.json()]
    listMarker = []
    for article in allArticle:
        listMarker.append((getLatLng(article.pk['address']),
                           article.pk['title'], article.pk['id']))

    return render(
        request, 'blog/home.html', {
            'articles': articles,
            'listMarker': listMarker,
            'territoires': get_territoire,
            'categories': get_category,
            'count': len(allArticle),
            'cpops': data
        })
Esempio n. 4
0
def updateArticle(request, id):
    places = [
        Place(place)
        for place in requests.get(BASE_URL + '/api/place/').json()
    ]
    url = BASE_URL
    instance = Capsule(
        requests.get(BASE_URL + '/api/capsule/' + str(id) + '/').json())
    return render(request, 'blog/updateArticle.html', locals())
Esempio n. 5
0
def all_territoires(request):
    territoires = requests.get(BASE_URL + '/api/place/',
                               headers=get_header(request))
    territoires = [Place(place) for place in territoires.json()]
    get_category = [1, 2, 3, 4]
    allArticle = requests.get(BASE_URL + '/api/capsule/')
    allArticle = [Capsule(article) for article in allArticle.json()]
    listMarker = []
    for article in allArticle:
        listMarker.append((getLatLng(article.pk['address']),
                           article.pk['title'], article.pk['id']))
    return render(
        request, 'blog/all_territoires.html', {
            'territoires': territoires,
            'categories': get_category,
            'listMarker': listMarker,
        })
Esempio n. 6
0
def toutes_les_capsules(request):
    articles = requests.get(BASE_URL + '/api/capsule/')
    get_article_from_image = requests.get(BASE_URL +
                                          '/api/capsule/category/1/').json()
    get_article_from_video = requests.get(BASE_URL +
                                          '/api/capsule/category/2/').json()
    get_article_from_son = requests.get(BASE_URL +
                                        '/api/capsule/category/3/').json()
    get_article_from_text = requests.get(BASE_URL +
                                         '/api/capsule/category/4/').json()

    #ull_profile = requests.get(BASE_URL + '/api/profile/full/'+str(id)+'/', headers=get_header(request)).json()
    #avatar = full_profile['profile']['picture']
    #city = full_profile['profile']['city']
    #user = full_profile['user']
    #get_parcours = full_profile['parcours']
    #Myarticle = full_profile['capsules']

    articles = [Capsule(article) for article in articles.json()]
    paginator = Paginator(articles, 6)
    page = request.GET.get('page', 1)
    try:
        article_page = paginator.page(page)
    except PageNotAnInteger:
        article_page = paginator.page(1)
    except EmptyPage:
        article_page = paginator.page(paginator.num_pages)
    territoires = requests.get(BASE_URL + '/api/place/',
                               headers=get_header(request))
    territoires = [Place(place) for place in territoires.json()]
    categories = [1, 2, 3, 4]
    return render(
        request, 'blog/toutes_les_capsules.html', {
            'articles': article_page,
            'count_post': len(articles),
            'territoires': territoires,
            'categories': categories,
            'count_image': len(get_article_from_image),
            'count_video': len(get_article_from_video),
            'count_son': len(get_article_from_son),
            'count_text': len(get_article_from_text)
        })
Esempio n. 7
0
def import_data():
    # Initial Imports
    from django.contrib.auth.models import User

    # Processing model: blog.models.Post

    from blog.models import Post

    blog_post_1 = Post()
    blog_post_1.author = importer.locate_object(
        User, "id", User, "id", 2, {
            'username':
            u'kumar',
            'first_name':
            u'',
            'last_name':
            u'',
            'is_active':
            True,
            'id':
            2,
            'is_superuser':
            False,
            'is_staff':
            True,
            'last_login':
            None,
            'password':
            u'pbkdf2_sha256$20000$oJcDd9UmNsJC$N1TM50Pb4acF8hkGfHi9toc1kdcfHqE1qG55+zBJYVQ=',
            'email':
            u'',
            'date_joined':
            datetime.datetime(
                2017, 5, 30, 1, 23, 8, tzinfo=timezone.get_default_timezone())
        })
    blog_post_1.email = u'*****@*****.**'
    blog_post_1.title = u'My first post'
    blog_post_1.text = u'Today we are learning about the django static files. we learned lot of good information which was relative to how to display the static files like css and java script. we learned about STATICFILES_DIR and we also learned about the STATIC_ROOT.'
    blog_post_1.created_date = dateutil.parser.parse(
        "2017-06-02T05:02:35+00:00")
    blog_post_1.published_date = dateutil.parser.parse(
        "2017-06-03T05:03:20+00:00")
    blog_post_1 = importer.save_or_locate(blog_post_1)

    blog_post_2 = Post()
    blog_post_2.author = importer.locate_object(
        User, "id", User, "id", 2, {
            'username':
            u'kumar',
            'first_name':
            u'',
            'last_name':
            u'',
            'is_active':
            True,
            'id':
            2,
            'is_superuser':
            False,
            'is_staff':
            True,
            'last_login':
            None,
            'password':
            u'pbkdf2_sha256$20000$oJcDd9UmNsJC$N1TM50Pb4acF8hkGfHi9toc1kdcfHqE1qG55+zBJYVQ=',
            'email':
            u'',
            'date_joined':
            datetime.datetime(
                2017, 5, 30, 1, 23, 8, tzinfo=timezone.get_default_timezone())
        })
    blog_post_2.email = u'*****@*****.**'
    blog_post_2.title = u' My second post'
    blog_post_2.text = u'we have already learned about templates. We are tyring to integrate the ORM backend data into our html pages.\r\nLets hope we will get the data from the backend database into our html pages.'
    blog_post_2.created_date = dateutil.parser.parse(
        "2017-06-03T05:03:25+00:00")
    blog_post_2.published_date = dateutil.parser.parse(
        "2017-06-03T05:03:53+00:00")
    blog_post_2 = importer.save_or_locate(blog_post_2)

    blog_post_3 = Post()
    blog_post_3.author = importer.locate_object(
        User, "id", User, "id", 2, {
            'username':
            u'kumar',
            'first_name':
            u'',
            'last_name':
            u'',
            'is_active':
            True,
            'id':
            2,
            'is_superuser':
            False,
            'is_staff':
            True,
            'last_login':
            None,
            'password':
            u'pbkdf2_sha256$20000$oJcDd9UmNsJC$N1TM50Pb4acF8hkGfHi9toc1kdcfHqE1qG55+zBJYVQ=',
            'email':
            u'',
            'date_joined':
            datetime.datetime(
                2017, 5, 30, 1, 23, 8, tzinfo=timezone.get_default_timezone())
        })
    blog_post_3.email = u'*****@*****.**'
    blog_post_3.title = u'third title'
    blog_post_3.text = u'This is the content for the django ORM shell'
    blog_post_3.created_date = dateutil.parser.parse(
        "2017-06-03T05:19:44+00:00")
    blog_post_3.published_date = None
    blog_post_3 = importer.save_or_locate(blog_post_3)

    blog_post_4 = Post()
    blog_post_4.author = importer.locate_object(
        User, "id", User, "id", 2, {
            'username':
            u'kumar',
            'first_name':
            u'',
            'last_name':
            u'',
            'is_active':
            True,
            'id':
            2,
            'is_superuser':
            False,
            'is_staff':
            True,
            'last_login':
            None,
            'password':
            u'pbkdf2_sha256$20000$oJcDd9UmNsJC$N1TM50Pb4acF8hkGfHi9toc1kdcfHqE1qG55+zBJYVQ=',
            'email':
            u'',
            'date_joined':
            datetime.datetime(
                2017, 5, 30, 1, 23, 8, tzinfo=timezone.get_default_timezone())
        })
    blog_post_4.email = u'*****@*****.**'
    blog_post_4.title = u'Fourth Post'
    blog_post_4.text = u'This is my fourth post'
    blog_post_4.created_date = dateutil.parser.parse(
        "2017-06-04T05:07:20+00:00")
    blog_post_4.published_date = None
    blog_post_4 = importer.save_or_locate(blog_post_4)

    blog_post_5 = Post()
    blog_post_5.author = importer.locate_object(
        User, "id", User, "id", 1, {
            'username':
            u'admin',
            'first_name':
            u'',
            'last_name':
            u'',
            'is_active':
            True,
            'id':
            1,
            'is_superuser':
            True,
            'is_staff':
            True,
            'last_login':
            datetime.datetime(2017,
                              6,
                              3,
                              5,
                              2,
                              3,
                              723738,
                              tzinfo=timezone.get_default_timezone()),
            'password':
            u'pbkdf2_sha256$20000$6SaVs1IyS9s5$s9h6o/ZZjpU1QYLICsYAChz22YN/2q+DR6lTpbkbCzU=',
            'email':
            u'*****@*****.**',
            'date_joined':
            datetime.datetime(2017,
                              5,
                              30,
                              0,
                              50,
                              23,
                              376400,
                              tzinfo=timezone.get_default_timezone())
        })
    blog_post_5.email = u'*****@*****.**'
    blog_post_5.title = u'Fifth Post'
    blog_post_5.text = u'I am good with the content writing. I am tying to test my django pages.'
    blog_post_5.created_date = dateutil.parser.parse(
        "2017-06-04T05:29:33+00:00")
    blog_post_5.published_date = dateutil.parser.parse(
        "2017-06-04T05:29:55+00:00")
    blog_post_5 = importer.save_or_locate(blog_post_5)

    blog_post_6 = Post()
    blog_post_6.author = importer.locate_object(
        User, "id", User, "id", 2, {
            'username':
            u'kumar',
            'first_name':
            u'',
            'last_name':
            u'',
            'is_active':
            True,
            'id':
            2,
            'is_superuser':
            False,
            'is_staff':
            True,
            'last_login':
            None,
            'password':
            u'pbkdf2_sha256$20000$oJcDd9UmNsJC$N1TM50Pb4acF8hkGfHi9toc1kdcfHqE1qG55+zBJYVQ=',
            'email':
            u'',
            'date_joined':
            datetime.datetime(
                2017, 5, 30, 1, 23, 8, tzinfo=timezone.get_default_timezone())
        })
    blog_post_6.email = u'*****@*****.**'
    blog_post_6.title = u'hello there'
    blog_post_6.text = u'hello there how are you doing.'
    blog_post_6.created_date = dateutil.parser.parse(
        "2017-06-10T05:34:12+00:00")
    blog_post_6.published_date = None
    blog_post_6 = importer.save_or_locate(blog_post_6)

    blog_post_7 = Post()
    blog_post_7.author = importer.locate_object(
        User, "id", User, "id", 1, {
            'username':
            u'admin',
            'first_name':
            u'',
            'last_name':
            u'',
            'is_active':
            True,
            'id':
            1,
            'is_superuser':
            True,
            'is_staff':
            True,
            'last_login':
            datetime.datetime(2017,
                              6,
                              3,
                              5,
                              2,
                              3,
                              723738,
                              tzinfo=timezone.get_default_timezone()),
            'password':
            u'pbkdf2_sha256$20000$6SaVs1IyS9s5$s9h6o/ZZjpU1QYLICsYAChz22YN/2q+DR6lTpbkbCzU=',
            'email':
            u'*****@*****.**',
            'date_joined':
            datetime.datetime(2017,
                              5,
                              30,
                              0,
                              50,
                              23,
                              376400,
                              tzinfo=timezone.get_default_timezone())
        })
    blog_post_7.email = u'*****@*****.**'
    blog_post_7.title = u'First blog of keethan'
    blog_post_7.text = u'Hey i am keerthan.'
    blog_post_7.created_date = dateutil.parser.parse(
        "2017-06-11T05:30:26+00:00")
    blog_post_7.published_date = None
    blog_post_7 = importer.save_or_locate(blog_post_7)

    # Processing model: blog.models.Publication

    from blog.models import Publication

    blog_publication_1 = Publication()
    blog_publication_1.title = u'ABC Publication'
    blog_publication_1 = importer.save_or_locate(blog_publication_1)

    blog_publication_2 = Publication()
    blog_publication_2.title = u'BCD Publication'
    blog_publication_2 = importer.save_or_locate(blog_publication_2)

    blog_publication_3 = Publication()
    blog_publication_3.title = u'CDE publication'
    blog_publication_3 = importer.save_or_locate(blog_publication_3)

    # Processing model: blog.models.Article

    from blog.models import Article

    blog_article_1 = Article()
    blog_article_1.headline = u'Bahubali'
    blog_article_1 = importer.save_or_locate(blog_article_1)

    blog_article_1.publications.add(blog_publication_1)
    blog_article_1.publications.add(blog_publication_2)
    blog_article_1.publications.add(blog_publication_3)

    blog_article_2 = Article()
    blog_article_2.headline = u'Sultan'
    blog_article_2 = importer.save_or_locate(blog_article_2)

    blog_article_2.publications.add(blog_publication_1)

    blog_article_3 = Article()
    blog_article_3.headline = u'Tubelight'
    blog_article_3 = importer.save_or_locate(blog_article_3)

    blog_article_3.publications.add(blog_publication_1)
    blog_article_3.publications.add(blog_publication_2)

    # Processing model: blog.models.Place

    from blog.models import Place

    blog_place_1 = Place()
    blog_place_1.name = u'Raghavendra'
    blog_place_1.address = u'Ameerpet'
    blog_place_1 = importer.save_or_locate(blog_place_1)

    blog_place_2 = Place()
    blog_place_2.name = u'Santosh Dhaba'
    blog_place_2.address = u'Paradise'
    blog_place_2 = importer.save_or_locate(blog_place_2)

    blog_place_3 = Place()
    blog_place_3.name = u'chutneys'
    blog_place_3.address = u'kukatpally'
    blog_place_3 = importer.save_or_locate(blog_place_3)

    # Processing model: blog.models.Restaurant

    from blog.models import Restaurant

    blog_restaurant_1 = Restaurant()
    blog_restaurant_1.place = blog_place_1
    blog_restaurant_1.serves_hot_dogs = True
    blog_restaurant_1.serves_pizza = False
    blog_restaurant_1 = importer.save_or_locate(blog_restaurant_1)

    blog_restaurant_2 = Restaurant()
    blog_restaurant_2.place = blog_place_2
    blog_restaurant_2.serves_hot_dogs = True
    blog_restaurant_2.serves_pizza = True
    blog_restaurant_2 = importer.save_or_locate(blog_restaurant_2)

    blog_restaurant_3 = Restaurant()
    blog_restaurant_3.place = blog_place_3
    blog_restaurant_3.serves_hot_dogs = False
    blog_restaurant_3.serves_pizza = True
    blog_restaurant_3 = importer.save_or_locate(blog_restaurant_3)

    # Processing model: blog.models.Waiter

    from blog.models import Waiter

    blog_waiter_1 = Waiter()
    blog_waiter_1.restaurant = blog_restaurant_2
    blog_waiter_1.name = u'kumar'
    blog_waiter_1 = importer.save_or_locate(blog_waiter_1)

    blog_waiter_2 = Waiter()
    blog_waiter_2.restaurant = blog_restaurant_2
    blog_waiter_2.name = u'santosh'
    blog_waiter_2 = importer.save_or_locate(blog_waiter_2)

    blog_waiter_3 = Waiter()
    blog_waiter_3.restaurant = blog_restaurant_3
    blog_waiter_3.name = u'santosh'
    blog_waiter_3 = importer.save_or_locate(blog_waiter_3)