curtwagner1984 / YAPO

Yapo - Yet Another Porn Organizer
GNU General Public License v3.0
48 stars 10 forks source link

[Feature Request] Add conversion display for Weight and Height to imperial measurement #20

Closed sjclayton closed 8 years ago

sjclayton commented 8 years ago

Add display similar to how a birthday is displayed underneath in (X Years Old) for the Weight and Height fields:

For Example: An entry in the Height field of 163 cm would be displayed underneath as (5 feet 4 inches) and a Weight of 54 kg would be displayed as (119 pounds)

sjclayton commented 8 years ago

@curtwagner1984 I think this link may help you out some: http://hawkee.com/snippet/9672/

curtwagner1984 commented 8 years ago

I get a 404 for this link

sjclayton commented 8 years ago

Try it now!! =P

sjclayton commented 8 years ago

@curtwagner1984

Implemented this! =D

EDIT: Maybe the function(s) can be cleaned up some.... eg. right now there are 2 separate functions for returning (Feet & Inches) for the height, as I couldn't figure out how to return them in the same function, or if it is even possible to do this (well I know it should be / is possible, I just don't know how to get it to display both from the same function in the AngularJS part in the markup).

curtwagner1984 commented 8 years ago

@sjclayton Indeed, there is no need for 2 functions here. What you basically do is convert cm to inches and then do an integer division to get the feet /12 or modulo to get the the remaining inches.

You could do simple js operations in the markup like so:

({{ $ctrl.heightConvertInches($ctrl.actor.height) / 12 }} feet {{ $ctrl.heightConvertInches($ctrl.actor.height) % 12}} inches)

(Provided that heightConvertInches returns the total amount of inches.) This works but it causes a problem. When doing / 12 it's returning a float and not an integer.

So we need to try another approach. We can try and output a dictionary instead of a single value, like so:

self.heightConvertInches = function (val) {

                var totalInches = Math.round(val / 2.54);

                var inches = totalInches % 12;
                var feet = Math.floor(totalInches / 12);

                var ans = {'inches': inches, 'feet': feet};
                return (ans)

            };

And then in the markup:

({{ $ctrl.heightConvertInches($ctrl.actor.height)['feet'] }} feet {{ $ctrl.heightConvertInches($ctrl.actor.height)['inches']}} inches)

Also, while you are on the case, can you convert the measurements values to cm ? Also, also, wouldn't it better to say 5"2' instead of 5 feet 2 inches ?

sjclayton commented 8 years ago

@curtwagner1984 Thanks for explaining things better, I am a bit rusty -- I haven't done much programming in quite some time (I'm actually a carpenter by trade =P)

The modifications you made look good overall -- the only thing is, the line you removed in the weightConvert function breaks it and returns incorrect values now. <--- EDIT: Maybe that's not it but it's returning incorrect values anyhow... like 59 kg to lbs should be: 130 lbs when rounded, but it's displaying 376 lbs.

^^ FIXED in latest commit!

Responding to your questions:

1) I could try writing something to convert things the other way for measurements, yes... but usually body measurements are standard in inches (unlike height and weight) regardless of where you're from (maybe I'm wrong... shrugs)..

The other issue with this is when converting the bust part of the measurement to cm, I don't know if that affects the cup size at all... or if it makes no difference (I'm pretty sure it does...), and I would have to look into how to do that part of it.

2) With this, I was trying to keep it in line with how you have the age displayed in 'Years Old' and also it is more readable / clear that way, than if it was (5 ft 2 in) or (5' 2") - also sites like IAFD and Freeones print it the way I have it.

sjclayton commented 8 years ago

@curtwagner1984 I did a little research into the conversion for body measurements (specifically bust).... and what I said above about converting the bra size to metric may be an issue.... because for example: someone with a standard North American 32C bra size (inches)... if you convert 32 to (cm) it would be 81, however with the way European bra sizing works they wouldn't be an 81C they'd be a 70C.

Frame of reference.... I'm Canadian BTW =P So we use a mix of Imperial and Metric measurements here for different things...

curtwagner1984 commented 8 years ago

@sjclayton Seems like too much work for feature that no one would really need. Leave it alone for now, if it will be needed we'll add it later on.

sjclayton commented 8 years ago

@curtwagner1984 I agree -- but you were the one who asked about it... ;)

P.S. How do I fix this...??? (The whole package requirements issue at the top) I've already set my Interpreter to the virtual environment I setup for YAPO, I was understanding that it was supposed to detect the install of Django and all that if that was done..

screenshot from 2016-08-30 13 54 52

Is it safe to just click 'Install requirements'? or...?

EDIT: Nevermind I'm blind... I got it fixed.

curtwagner1984 commented 8 years ago

@sjclayton If you work with a virtual environment you need to set it up in pycharm so it will use the virtualenv you installed Yapo with.

https://www.jetbrains.com/help/pycharm/2016.1/creating-virtual-environment.html

https://www.jetbrains.com/help/pycharm/2016.1/adding-existing-virtual-environment.html

This only applies if you installed Yapo with a virtual environment.

sjclayton commented 8 years ago

@curtwagner1984 Yeah I figured out how to do it.... as I mentioned at the end of my last post =P

Thanks for the links though, I'm still going to look at them.