GithubHelp home page GithubHelp logo

bekeplar / ireporter Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 344 KB

iReporter enables any/every citizen to bring any form of corruption to the notice of appropriate authorities and thegeneral public. Users can also report on things that needs government intervention

License: MIT License

ireporter's People

Contributors

bekeplar avatar

Stargazers

 avatar

Watchers

 avatar

ireporter's Issues

Some programming logic issues

Why did you create two validation functions and not one instead?

def validate_input(self):
error = None
if not self.firstname or self.firstname.isspace():
error = 'Please fill in firstname field!'
elif not self.lastname or self.lastname.isspace():
error = 'Please fill in lastname field!'
elif not self.othernames or self.othernames.isspace():
error = 'Please fill in othernames field!'
if not self.username or self.username.isspace():
error = 'Please fill in username field!'
if not self.isAdmin or self.isAdmin.isspace():
error = 'Please select user role!'
return error
def validate_inputs(self):
errors = None
if not self.email or self.email.isspace():
errors = 'Please fill in email field!'
elif not self.phoneNumber or self.phoneNumber.isspace():
errors = 'Please fill in phoneNumber field!'
elif not re.match(r"[^@.]+@[A-Za-z]+\.[a-z]+", self.email):
errors = 'Please fill in right email format!.'
elif not self.password or self.password.isspace():
errors = 'Plese fill in password field!'
elif len(self.password) < 8:
errors = 'Password must be of 8 characters long!'
return errors

What's the essence of validate_input and validate_inputs? Why not have one continuous function?

iReporter/api/Helpers.py

Lines 17 to 21 in 887c8a7

def create_user(username, password):
"""function to create a new user. """
for user in users:
if user.username == None:
users.append(user)

What does this function do? I do not understand the logic. if user.username == None:

If your target is to avoid adding a duplicate user then you would loop through a list of user objects while comparing the username or email or both and if there is a match then user already exists.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.