Today, I added a
Total Length property to the rebar object. Total length is the length of the individual rebar multiplied by the number of occurrences of the rebar. Below is a screenshot of rebar object properties. See the Length and Total Length property in property value table.
Yesterday, I also had a discussion with Sean regarding GCI tasks. He told about interoperability task (for eg. export FreeCAD model to BRL-CAD).
Today, I introduced a new property in the rebar object of FreeCAD i.e. Length. This property calculates the total length of the rebar. The user will see this property in the property value table. This property is very useful for Bar bending schedule.
Below is the code which calculates the length of rebar:
""" getLengthOfRebar(RebarObject): Calculates the length of the rebar."""
base = rebar.Base
# When rebar is derived from DWire
if hasattr(base, "Length"):
# When rebar is derived from Sketch
length = 0
for geo in base.Geometry:
length += geo.length()
FreeCAD.Console.PrintError("Cannot calculate rebar length from its base object\n")
Today, I have solved LibreHatti issue. It just took less than my 20 minutes. By reverse engineering, I easily found how to fix the issue. Today, I also learnt how to use Ajax in Django and a little bit JQuery for LuvLdh web app.
Django provides a decorator called
login_required that takes one of your views and prevents a user from seeing it unless they are logged in. Every time we need to add this decorator above view. Sometimes it’s a real pain to use the
login_required decorator all over the views of your complicated site. What if you forget to add it to view that contains sensitive information?
Django allows you to write middleware that gets access to each request so you can add functionality that can be applied to your whole site. My middleware simply intercepts each request and redirects users to the site login page if they haven’t logged in. It also allows you to give of exceptions (in the form of regular expressions), i.e. pages that can be viewed without logging in.
from django.http import HttpResponseRedirect
from django.conf import settings
from re import compile
EXEMPT_URLS = [compile(settings.LOGIN_URL.lstrip('/'))]
if hasattr(settings, 'LOGIN_EXEMPT_URLS'):
EXEMPT_URLS += [compile(expr) for expr in settings.LOGIN_EXEMPT_URLS]
Middleware that requires a user to be authenticated to view any page other
than LOGIN_URL. Exemptions to this requirement can optionally be specified
in settings via a list of regular expressions in LOGIN_EXEMPT_URLS (which
you can copy from your urls.py).
Requires authentication middleware and template context processors to be
loaded. You'll get an error if they aren't.
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
print "settings.DEBUG: ", settings.DEBUG
assert hasattr(request, 'user'), "The Login Required middleware\
requires authentication middleware to be installed. Edit your\
MIDDLEWARE setting to insert\
'django.contrib.auth.middleware.AuthenticationMiddleware'. If that doesn't\
work, ensure your TEMPLATE_CONTEXT_PROCESSORS setting includes\
if not request.user.is_authenticated():
path = request.path_info.lstrip('/')
if not any(m.match(path) for m in EXEMPT_URLS):
Change or add
settings.py file as given below:
LOGIN_URL = '/login/'
LOGIN_EXEMPT_URLS = (
MIDDLEWARE_CLASSES = (
Here is my login_required_middleware.py and settings.py file.
Given a user instance, you can get the token by doing this:
social = request.user.social_auth.get(provider='provider name')
Assuming Facebook provider:
social = request.user.social_auth.get(provider='facebook')
In LuvLdh web app I used
social-auth-pipeline to get extra information from Facebook API response like access_token etc. I have known that using the pipeline for getting information was not a good way but I used it in the app. I have searched it on Google that how to get access_token from Django request but I didn’t found any fruitful result. Today, I searched it on DuckDuckGo instead of Google and I amazed that DuckDuckGo gave an answer of my query in the first link.
Today, I figured out social-auth-pipeline in Django. With this pipeline, we can control and manipulate the flow of user request. I also designed the basic workflow of LuvLdh web app and did some magic with access token using GraphAPI.
Today, I helped Abhinav Handa’s to solving his problem. Actually, he wants to create a dropdown list in a header of OSM map but OSM overlapped drop-down list. When I searched it on the internet and heard new property in the CSS i.e.
z-index. After using
z-index then I came to know that every page rendering on the browser has at-least one layer like we use simple
div tags in an HTML page then all
div is under one layer.
Div tag(assume as a layer) which has greater
z-index value can overwrite all other div’s.
Everywhere fundamentals are same, we just trying to understand by taking some real world example.:)
Today, it was the first time when I was the only one who was present in TCC. I have written the half code of the slab with rebar and watched some videos on topics “what is DFA, NDFA and conversion from NDFA to DFA”. There was no any distrubance which increased my effiency to work more.
In this diary, I write about past two or three days that were very big for me. I was shocked about sir’s decision that I’m out from GD and they told me to investigate the reason that why you are out from GD? But I unable to found it. In this period, I felt very bored. But it was a new experience for me which told me how GD plays an important in my life.