Opened 13 years ago

Last modified 13 years ago

#87 closed defect (FIXED)

Ability to create users from command line

Reported by: Christopher Allan Webber Owned by: Alejandro Villanueva
Priority: minor Milestone: 0.0.3
Component: programming Keywords:
Cc: Parent Tickets:

Description

A script like:

::

    ./bin/gmg adduser <username> <password> <email>

is clearly needed.

We could also use:

::

    ./bin/gmg makeadmin <username>
    ./bin/gmg changepw <username>

for making an existing user an admin or changing a user's
password.



Attachments (3)

patch.tar.gz (1.4 KB ) - added by Alejandro Villanueva 13 years ago.
patch.tar.gz
0003-Add-changepw-and-makeadmin-to-gmg-commands.patch.tar.gz (1.2 KB ) - added by Alejandro Villanueva 13 years ago.
0003-Add-changepw-and-makeadmin-to-gmg-commands.patch.tar.gz
0002-Adding-new-function-to-gmg_commands-adduser-makeadmi.patch.tar.gz (1.6 KB ) - added by Alejandro Villanueva 13 years ago.
0002-Adding-new-function-to-gmg_commands-adduser-makeadmi.patch.tar.gz

Download all attachments as: .zip

Change History (15)

by Alejandro Villanueva, 13 years ago

Attachment: patch.tar.gz added

patch.tar.gz

comment:1 by Alejandro Villanueva, 13 years ago

Just implement CLI support to add users, it does NOT validate the
email, and the connection is hardcoded i couldn't find the way to
create the conn from the app\_config.

Usage: ./bin/gmg adduser -u ialex -p secretword -m
`admin@ialex.org <mailto:admin@ialex.org>`_

The user doesn't need verification after created.



comment:2 by Christopher Allan Webber, 13 years ago

Status: NewIn Progress
Hey, thanks for this patch(es)!

Yeah the config stuff / setting up a connection is going to be
refactored soon and is currently a mess. I'll look at merging this
shortly.

I've added you to the hackers/reporters lists in redmine.



by Alejandro Villanueva, 13 years ago

0003-Add-changepw-and-makeadmin-to-gmg-commands.patch.tar.gz

comment:3 by Alejandro Villanueva, 13 years ago

I added the another two commands mentioned on the feature, now we
can change passwords and make admin to already registeres users.

usage: ./bin/gmg makeadmin-u username
usage: ./bin/gmg changepw -u username -p new\_password

need some testing to see if everything works fine at least for me
it does, and change the database stuff mentioned earlier.



comment:4 by Christopher Allan Webber, 13 years ago

First of all, sorry that it's taken me so long to comment on this.
Second, thanks for all the work you've done on this... you got all
three commands, nice!

That said, I'm hoping you can make a few adjustments before I merge
this.


-  Try and make sure your code is PEP-8 compliant.
   `http://www.python.org/dev/peps/pep-0008/ <http://www.python.org/dev/peps/pep-0008/>`_
   ... in pacticular:
   
   -  Avoid going over 80 characters (right now it's just your
      comments that have done this, so please wrap them)
   -  when doing an if statement, no need to do "if (foo bar):"... in
      python "if foo bar:" more appropriate
   -  Put two newlines between your functions

-  Pull the connection information out of the config. Yeah, okay,
   not your fault, and you already acknowledged this :). Here's how to
   do it:

Look at the way that gmg\_commands/shell.py does it:

::

    from mediagoblin import mg_globals
    from mediagoblin.gmg_commands import util as commands_util
    
    def shell_parser_setup(subparser):
        subparser.add_argument(
            '-cf', '--conf_file', default='mediagoblin.ini',
            help="Config file used to set up environment")
    
    [...]
    
    def shell(args):
        """ 
        Setup a shell for the user
        """ 
        mgoblin_app = commands_util.setup_app(args)

... After you do this, you'll have access to the database through
"mg\_globals.database".

Looking good though! Add this stuff in another patch and I think we
can probably merge this. If you don't have time / can't do this,
let us know. Otherwise looking forward to seeing that patch!



comment:5 by Alejandro Villanueva, 13 years ago

It's Monday and its time to work, will work on that today i will
put everything on a branch since im tired of patches haha, i'll
send the corrections greetz



comment:6 by Christopher Allan Webber, 13 years ago

Component: Programming
Milestone: 0.0.3
Owner: set to Alejandro Villanueva
Wonderful! I prefer patches also. I've assigned this to you and
targeting to 0.0.3 because that looks likely and reasonable now.



by Alejandro Villanueva, 13 years ago

0002-Adding-new-function-to-gmg_commands-adduser-makeadmi.patch.tar.gz

comment:7 by Alejandro Villanueva, 13 years ago

Component: Programming
Milestone: 0.0.3
Owner: set to Alejandro Villanueva
here is the patch, made changes to be pep8 compatible, and change
the database stuff.



comment:8 by Alejandro Villanueva, 13 years ago

Component: Programming
Owner: set to Alejandro Villanueva

comment:8 by Christopher Allan Webber, 13 years ago

Looking! Btw, I said "I prefer patches also" and meant "I prefer
branches also", so if you'd rather work in branches from now on
please, by all means ;)



comment:9 by Christopher Allan Webber, 13 years ago

Milestone: 0.0.3
Merged! I also made a bit of a change and made the arguments
positional instead.

Thanks for your work on this Alejandro, wonderful job!



comment:10 by Alejandro Villanueva, 13 years ago

Status: In ProgressClosed
Great! time to close this feature



comment:11 by Will Kahn-Greene, 13 years ago

The original url for this bug was http://bugs.foocorp.net/issues/373 .
Relations:
#88: blocks

Note: See TracTickets for help on using tickets.